1
我真的很想知道,为什么下面的代码总是返回7.我真的很困惑。为什么这些表达式总是返回7?
$a = (double) ((0.1 + 0.6) * 10); //Output: 7
$b = (int) ((0.1 + 0.6) * 10); //Output: 7
$c = (int) ((0.1 + 0.7) * 10); //Output: 7
输出测试:
echo ($a == $b && $a == $c); //Output: true
看到http://stackoverflow.com/questions/3726721/php-floating-number-precision – jeroen