Analyze several ways of php integer

  • 2020-06-19 09:59:39
  • OfStack

floor floor (float value)
Returns the next integer not greater than value, rounding off the decimal portion of value. The type returned by floor() is still float, because the range of float values is usually larger than integer.
echo floor(4.3); // 4
echo floor(9.999); // 9

ceil 1: float ceil (float value)
Returns the next integer not less than value, carrying 1 digit if value has a decimal part. The type returned by ceil() is still float, because the range of float values is usually larger than integer
echo ceil(4.3); // 5
echo ceil(9.999); // 10

round rounds four to five floating-point Numbers
Grammar :float round (float val [, int precision])
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

Related articles: