Do math operation for 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.add(decimalB); System.out.println("decimalA = " + decimalA); decimalA = decimalA.multiply(decimalB); System.out.println("decimalA = " + decimalA); decimalA = decimalA.subtract(decimalB); System.out.println("decimalA = " + decimalA); decimalA = decimalA.divide(decimalB); System.out.println("decimalA = " + decimalA); decimalA = decimalA.pow(2); System.out.println("decimalA = " + decimalA); decimalA = decimalA.negate(); System.out.println("decimalA = " + decimalA); } }