Calculate the power of a big decimal in Java
Description
The following code shows how to calculate the power of a big decimal.
Example
/*from w w w.j ava 2 s. co m*/
import java.math.BigDecimal;
public class Main {
public static void main(String[] args) {
BigDecimal decimalA = new BigDecimal("123456789012345");
BigDecimal decimalB = new BigDecimal("10");
decimalA = decimalA.pow(2);
System.out.println("decimalA = " + decimalA);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »