Home >Backend Development >PHP Problem >Why doesn't php round to the nearest whole number?

Why doesn't php round to the nearest whole number?

藏色散人
藏色散人Original
2021-11-23 09:26:373135browse

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.

Why doesn't php round to the nearest whole number?

#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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn