将数据存储到字符串,通过java.math.BigDecimal转为任意精度的有符号十进制数
String x = "10000000000000000000000";
BigDecimal bd1 = new BigDecimal(x);
BigDecimal bd2 = new BigDecimal(x);
System.out.println(bd1.add(bd2));
System.out.println(bd1.subtract(bd2));
System.out.println(bd1.multiply(bd2));
System.out.println(bd1.subtract(bd2)); |