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