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); // 3intval(3.64159); // 3intval('ruesin')//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); // 3round(3.64159); // 4round(3.641590); // 4round(3.641592); // 3.64round(5.641593); // 3.642round(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); // 4ceil(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); // 3floor(3.64159); // 3
Reprint Please specify source: http://blog.csdn.net/churk2012/article/details/51424588
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
The above introduces the PHP rounding, rounding round rounding, up rounding, down rounding, fractional interception, including rounding, PHP content, I hope that the PHP tutorial interested friends have helped.