Java Utililty Methods BigInteger Power

List of utility methods to do BigInteger Power

Description

The list of methods to do BigInteger Power are organized into topic(s).

Method

BigIntegerpow(BigInteger base, BigInteger exponent)
pow
BigInteger result = BigInteger.ONE;
while (exponent.signum() > 0) {
    if (exponent.testBit(0))
        result = result.multiply(base);
    base = base.multiply(base);
    exponent = exponent.shiftRight(1);
return result;
...
BigIntegerPower(BigInteger base, int exp)
Power
BigInteger powerResultat = new BigInteger("1");
if (exp == 1) {
    return base;
if (exp == 0) {
    return powerResultat;
for (int i = 0; i < exp; ++i) {
...
BigIntegerpowerToEnergy(BigInteger power, Integer ptuDuration)
Transforms a power (Watt) of a PTU to an energy (Watt hour).
BigDecimal hoursPerPtu = new BigDecimal(Hours.ONE.toStandardMinutes().getMinutes())
        .divide(new BigDecimal(ptuDuration), DECIMAL_PRECISION, RoundingMode.HALF_UP);
return new BigDecimal(power).divide(hoursPerPtu, DECIMAL_PRECISION, RoundingMode.HALF_UP).toBigInteger();