Java BigDecimal
new BigDecimal 对象时,确定的数字用String作为参数,否则会出现精度问题
BigDecimal b1 = new BigDecimal(0.7); //0.69999999999999995559107901499373838305473...
BigDecimal b2 = new BigDecimal("0.7"); //0.7
System.out.println(b1.compareTo(b2)); // 结果 -1
Copyright © 2018-02-13 XIAOZHUO.WANG™