Home > Article > Backend Development > Why doesn’t php round to the nearest whole number?
php method of rounding without rounding: 1. Use the ceil() method to achieve further rounding; 2. Use the floor() method to achieve rounding to an integer.
#The operating environment of this article: Windows7 system, PHP7.1, Dell G3 computer.
Why doesn’t php round up?
php rounding method
The code is as follows:
echo ceil(4.3); // 5 echo ceil(9.999); // 10
php rounding method, rounding up an integer
The code is as follows:
echo floor(4.3); // 4 echo floor(9.999); // 9
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of Why doesn’t php round to the nearest whole number?. For more information, please follow other related articles on the PHP Chinese website!