double a = 1.0;
double b = 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1; System.out.println("a=" + a + ";b=" + b); System.out.println(a == b); System.out.println(Math.abs(a - b) < 1e-6);本文共 251 字,大约阅读时间需要 1 分钟。
double a = 1.0;
double b = 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1; System.out.println("a=" + a + ";b=" + b); System.out.println(a == b); System.out.println(Math.abs(a - b) < 1e-6);转载于:https://www.cnblogs.com/zoudajia/p/5497767.html