1.不四舍五入:
floor函数,去小数点后两位,需要先乘以100,然后舍去取整,再除以100,即:
echo floor(3.14159*100)/100 = 3.14
拓展:
echo floor(3.1) = 3
echo floor(3.9) = 3
echo ceil(3.1) = 4
echo ceil(3.9) = 4
2.四舍五入:
round函数:
echo round(3.14159,2) = 3.14
拓展:
echo round(3.14159) = 3
echo round(3141.59,-2) = 3100
网友评论