PHP takes integer functions commonly used in four ways:
1. Direct rounding, discarding decimals, preserving integers: intval ();
2 Rounding and Rounding: round ();
3. Rounding up, there are decimals on the addition of 1:ceil ();
4. Rounding Down: Floor ().
First, intval-the variable into an integer form
Intval if it is a character type, it is automatically converted to 0.
intval (3.14159); // 3 intval (3.64159); // 3 intval // 0
Second, rounding: round ()
The parameter 1 is rounded according to the specified precision of parameter 2. The parameter 2 can be a negative number or 0 (the default).
round (3.14159); // 3 round (3.64159); // 4 round (3.64159, 0); // 4 round (3.64159, 2); // 3.64 round (5.64159, 3); // 3.642 round (364159,-2); // 364200
Three, upward rounding, there are decimals on the addition of 1:ceil ()
Returns the next integer not less than value, in which value is entered if there is a fractional part.
This method is often used when we are writing pagination classes to calculate page counts.
Ceil (3.14159); // 4 Ceil (3.64159); // 4
Four, downward rounding: Floor ()
Returns the next integer not less than value, rounding out the fractional part of value.
Floor (3.14159); // 3 Floor (3.64159); // 3
PHP rounding, rounding round rounding, rounding up, rounding down, fractional interception