Home > Article > Backend Development > How to round without rounding in php
In PHP, you can use the floor function to perform rounding without rounding. The syntax format of this function is "float floor (float value)", which returns the next integer that is not greater than value, and replaces value with Decimal parts are rounded off.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
floor rounding
Syntax format: float floor (float value)
Returns the next integer that is not greater than value, and rounds the decimal part of value.
The type returned by floor() is still float, because the range of float values is usually larger than that of integer.
echo floor(4.3); // 4 echo floor(9.999); // 9
floor() function introduction
floor() function rounds down to the nearest integer.
Syntax
floor(x)
Parameters
x Required. A number.
Description
Returns the next integer not greater than x, and rounds the decimal part of x. The type returned by floor() is still float because the range of float values is usually larger than that of integer.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to round without rounding in php. For more information, please follow other related articles on the PHP Chinese website!