Java BigInteger Power Power(BigInteger base, int exp)

Here you can find the source of Power(BigInteger base, int exp)

Description

Power

License

Open Source License

Declaration

static public BigInteger Power(BigInteger base, int exp) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.math.BigInteger;

public class Main {

    static public BigInteger Power(BigInteger base, int exp) {
        BigInteger powerResultat = new BigInteger("1");
        if (exp == 1) {
            return base;
        }/*ww w .  j av  a2 s  . c  om*/
        if (exp == 0) {
            return powerResultat;
        }
        for (int i = 0; i < exp; ++i) {
            powerResultat = powerResultat.multiply(base);
        }
        return powerResultat;
    }
}

Related

  1. pow(BigInteger base, BigInteger exponent)
  2. powerToEnergy(BigInteger power, Integer ptuDuration)