# PHP Version 5.2.9
$a = 0.6/0.1;
$b = $a % 5;
print "\$a=$a; \$b=$b\n";
# result:
# $a=6; $b=0 # One should expect $b = 1
$a = 0.6/0.1;
$a = round($a);
$b = $a % 5;
print "\$a=$a; \$b=$b\n";
# result:
# $a=6; $b=1 # result as expected
为什么在第一种情况下结果 $b=0 。
为什么 round() 函数似乎解决了这个问题?