Php & nbsp; usually needs to be rounded off when processing floating point numbers. There are three functions in php & nbsp; for this situation: floor function, ceil function, and round function. The combination of floor and ceil functions makes the data processed by php & nbsp; more authentic and reliable. I. First, let's look at the floor function: syntax: floatfloor (
Php? When processing floating point numbers, it is often necessary to rounding. In php? There are three functions that apply to this situation:Floor function, ceil function, and round function.
The floor function and ceil function work together to make php? The processed data is more authentic and reliable.
I. First, let's look at the floor function:
Syntax:
float floor ( float value )
Note:
Returns the next integer not greater than value and rounds the decimal part of value. The return type of floor () is still float, because the float value range is usually larger than that of integer.
Floor ()? Example
II. ceil functions:
Syntax:
float ceil ( float value )
Note:
Returns the next integer of no less than value. if the value has a decimal part, it is entered in one place. The type returned by ceil () is still float, because the float value range is usually larger than integer.
Ceil ()? Example:
See the differences between the two functions ..
Of course, you need to useRoundFunction.
III. round functions:
Syntax:
float round ( float val [,?int?precision] )
Note:
Returns the result of rounding val by the specified precision (number of digits after decimal point. Precision can also be negative or zero (default ).
Round ()? Example