Calculate the power on a BigInteger in Java
Description
The following code shows how to calculate the power on a BigInteger.
Example
/* w ww . ja v a2 s .co m*/
import java.math.BigInteger;
public class Main {
public static void main(String[] argv) throws Exception {
BigInteger bi1 = new BigInteger("1234567890123456890");
int exponent = 2;
bi1 = bi1.pow(exponent);
System.out.println(bi1);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »