标签:round 比较 int == pre php 浮点数 表示 blog
<?php echo "<br>"; printf ( "%01.53f" , 0.8 );//53位小数表示0.8 echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>"; printf ( "%01.53f" , round(0.1+0.7,15) );//精确到15位小数 echo "<br>"; printf ( "%01.53f" , round(0.8,15) );//精确到15位小数 echo "<br>"; printf ( "%01.53f" , (0.1+0.7) ); echo "<br>"; printf ( "%01.53f" , 0.8 ); echo "<br>"; var_dump(round(0.1+0.7,15)==round(0.8,15));//如果精确到小数点后15为,则看第16位,是9,所以进1,所以和0.8相同 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,16)==round(0.9,16));
标签:round 比较 int == pre php 浮点数 表示 blog
原文地址:http://www.cnblogs.com/ch459742906/p/7421091.html