为什么它等于总是假的?
<?php
$a = (0.1+0.2);
print $a."\n"; // results in 0.3
if ( (double)$a == (double)0.3 ) {
echo "true";
}else{
echo "not true";
}
echo PHP_EOL;
Perl
perl -e 'if ((0.2+0.1) == 0.3) {print "true\n"; } else { print "false\n"; }'
现在在 Python 中
python -c 'if ((0.2+0.1)!=0.3 ): print "false" '