public static void main(String[] args) { // 双精度计算 double x = 4.85; double y = 6600.00; double z = x * y; System.out.println(z);//32009.999999999996 BigDecimal a = BigDecimal.valueOf(x); BigDecimal b = BigDecimal.valueOf(y); BigDecimal c = a.multiply(b); System.out.println(c);//32010.00 }
Java双精度相乘,结果错误的解决,布布扣,bubuko.com
原文地址:http://blog.csdn.net/yueritian/article/details/26282797