- Echo ceil (4.3); // 5
- Echo ceil (9.999); // 10
- ?>
2. the floor-rounding method returns the next integer not greater than the value of float floor (float $ value) and rounds the fractional part of the value. The return type of floor () is still float, because the float value range is usually larger than that of integer. Floor () example
- Echo floor (4.3); // 4
- Echo floor (9.999); // 9
- ?>
3. round-rounding a floating point number indicates float round (float $ val [, int $ precision]). return the value of val based on the specified precision (number of digits after decimal point) result of rounding. Precision can also be negative or zero (default ). Round () example
- Echo round (3.4); // 3
- Echo round (3.5); // 4
- Echo round (3.6); // 4
- Echo round (3.6, 0); // 4
- Echo round (1.95583, 2); // 1.96
- Echo round (1241757,-3); // 1242000
- Echo round (5.045, 2); // 5.05
- Echo round (5.055, 2); // 5.06
- ?>
-
Note: PHP cannot properly process strings similar to "12,300.2" by default. Note: the precision parameter is introduced in PHP 4. 4. intval-get the integer value of the variable. int intval (mixed $ var [, int $ base]) is converted by a specific hexadecimal conversion (decimal by default ), returns the integer value of the variable var. Var can be any scalar type. Intval () cannot be used for array or object. Intval () example
- Echo intval (4.3); // 4
- Echo intval (9.999); // 9
- ?>
-
Note: The base parameter of intval () does not work unless the var parameter is a string. Conclusion: The floor function has the same function as the intval function. The difference is that a floating point number (float) is returned, and the other is an integer, because the float value range is usually larger than that of an integer. However, the values are equal. |