比较 0.2+0.7 与 0.9
0.89999999999999991118215802998747676610946655273437500
0.90000000000000002220446049250313080847263336181640625
0.89999999999999991118215802998747676610946655273437500
0.90000000000000002220446049250313080847263336181640625
echo "<br>";
printf ( "%01.53f" , (0.2+0.7) );
echo "<br>";
printf ( "%01.53f" , 0.9 );
echo "<br>";
var_dump(round(0.2+0.7,15)==round(0.9,15));//结果为true,精确到小数点后15位,则看第16位,是9,所以进1,所以和0.8相同(上面浮点数中的蓝色部分)
var_dump(round(0.2+0.7,16)==round(0.9,16));//结果为false精确到小数点后16位,则看第17位,是1,所以不进1,所以不等于0.8(上面浮点数中的黄色部分)