Power a BigDecimal
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);
}
}
Output:
decimalA = 15241578753238669120562399025
Home
Java Book
Runnable examples
Java Book
Runnable examples
BigDecimal:
- Create BigDecimal from long and String
- Add two BigDecimal together
- Divide BigDecimal from another BigDecimal
- Multiply one BigDecimal to another BigDecimal
- Negate a BigDecimal
- Subtract BigDecimal from another BigDecimal
- Truncate BigDecimal value
- Power a BigDecimal
- Round a BigDecimal(double) up
- Round a BigDecimal(double) down
- Format BigDecimal to Currency and Percentage