java下double乘以100后精度丢失问题
比如
System.out.println(0.14*100);
输出: 14.000000000000002
解决方法:
BigDecimal b = new BigDecimal(String.valueOf(0.14));
BigDecimal c = new BigDecimal(String.valueOf(100));
System.out.println(b.multiply(c));
System.out.println(b.multiply(c).intValue());
System.out.println(b.multiply(c).doubleValue());
输出:
14.00
14
14.0