Ceil is a function for getting a value from the up position; floor is a function for rounding out the decimal places to get a value; round is a function for rounding out. Ceil definition and usage: the ceil () function rounds up to the nearest integer. [Php] ceil (x); Description: return the next integer not less than x. If x has a decimal part, the return value is one. Ceil (
Ceil is a function for getting a value from the up position; floor is a function for rounding out the decimal places to get a value; round is a function for rounding out. Ceil definition and usage: the ceil () function rounds up to the nearest integer. [Php] ceil (x); Description: return the next integer not less than x. If x has a decimal part, the return value is one. Ceil (
Ceil is a function that returns a value in the ascending order;
Floor is a function used to remove the decimal places to get a value;
Round is a rounding function.
Ceil
Definition and usage:
The ceil () function rounds up to the nearest integer.
[Php]
Ceil (x );
Ceil (x );
Note:
Returns the next integer of no less than x. If x has a decimal part, the return value is one digit.
The type returned by ceil () is still float.
Example:
[Php]
Echo ceil (1, 0.60 );
Echo"
Echo ceil (1, 0.40 );
Echo"
Echo ceil (5 );
Echo"
Echo ceil (1, 5.1 );
Echo"
Echo ceil (-5.1 );
Echo"
Echo ceil (-5.9 );
?>
Echo ceil (1, 0.60 );
Echo"
Echo ceil (1, 0.40 );
Echo"
Echo ceil (5 );
Echo"
Echo ceil (1, 5.1 );
Echo"
Echo ceil (-5.1 );
Echo"
Echo ceil (-5.9 );
?>
Output:
[Php]
1
1
5
6
-5
-5
1
1
5
6
-5
-5
Floor
Definition and usage:
The floor () function rounds down to the nearest integer.
[Php]
Floor (x );
Floor (x );
Note:
Returns the next integer not greater than x and rounds the decimal part of x.
The returned type of floor () is still float.
Example:
[Php]
Echo (floor (0.60 ));
Echo"
";
Echo (floor (0.40 ));
Echo"
";
Echo (floor (5 ));
Echo"
";
Echo"
";
Echo (floor (5.1 ));
Echo"
";
Echo (floor (-5.1 ));
Echo"
";
Echo (floor (-1, 5.9 ))
?>
Echo (floor (0.60 ));
Echo"
";
Echo (floor (0.40 ));
Echo"
";
Echo (floor (5 ));
Echo"
";
Echo"
";
Echo (floor (5.1 ));
Echo"
";
Echo (floor (-5.1 ));
Echo"
";
Echo (floor (-1, 5.9 ))
?>
Output:
[Php]
0
0
5
5
-6
-6
0
0
5
5
-6
-6
Round
Definition and usage
The round () function rounds a floating point number.
[Php]
Round (x, prec );
Round (x, prec );
Where
X (optional) specifies the number to be rounded.
Prec (optional) specifies the number of digits after the decimal point.
Note:
Returns the result of rounding x to the specified precision prec (number of digits after decimal point.
Prec can also be a negative number or zero (default ).
Example:
[Php]
Echo round (12.345,-1 );
Echo"
Echo round (12.345 );
Echo"
Echo round (0.5 );
Echo"
Echo round (0.4 );
Echo"
Echo round (-0.5 );
Echo"
Echo round (-0.4 );
?>
Echo round (12.345,-1 );
Echo"
Echo round (12.345 );
Echo"
Echo round (0.5 );
Echo"
Echo round (0.4 );
Echo"
Echo round (-0.5 );
Echo"
Echo round (-0.4 );
?>
Output:
[Php]
10
12
1
0
-1
-0