援引自博文 https://blog.csdn.net/hongxiaoshuang/article/details/54598757
ceil -- 进一法取整
float ceil ( float value )
返回不小于 value 的下一个整数,value 如果有小数部分则进一位。ceil() 返回的类型仍然是 float,因为 float 值的范围通常比 integer 要大。
eg.
< ?php
echo ceil(2.3); // 3
echo ceil(1.999); // 2
?>
floor -- 舍去法取整
float floor ( float value )
返回不大于 value 的下一个整数,将 value 的小数部分舍去取整。floor() 返回的类型仍然是 float,因为 float 值的范围通常比 integer 要大。
eg.
< ?php
echo floor(4.3); // 4
echo floor(9.999); // 9
?>
round -- 对浮点数进行四舍五入
float round ( float val [, int precision] )
返回将 val 根据指定精度 precision(十进制小数点后数字的数目)进行四舍五入的结果。precision 也可以是负数或零(默认值)。
eg.
< ?php
echo round(3.4); // 3
echo round(3.5); // 4
echo round(3.6); // 4
echo round(3.6, 0); // 4
echo round(1.95583, 2);// 1.96
echo round(1241757, -3); // 1242000
echo round(5.045, 2); // 5.05
echo round(5.055, 2); // 5.06
?>
intval---对变数转成整数型态
< ?php
echo intval(4.3); //4
echo intval(4.6); //4
?>