A ceil is a function that gets a value upward;
Floor is the function of rounding out the decimal place to get a value;
Round is a function for rounding.
Ceil
Definition and Usage:
The Ceil () function rounds up to the nearest integer.
Copy the Code code as follows:
Ceil (x);
Description
Returns the next integer not less than x, or x if there are fractional parts.
The type returned by Ceil () is still float.
Example:
copy code code as follows:
!--? php echo ceil (0.60);
echo "
";
Echo ceil (0.40);
echo "
";
Echo ceil (5);
echo "
";
echo ceil (5.1);
echo "
";
Echo ceil (-5.1);
echo "
";
Echo ceil (-5.9);
?
output:
copy Code The code is as follows:
1
1
5
6
-5
-5
floor
Definition and usage:
floor () The function is rounded down to the nearest integer.
copy code code is as follows:
floor (x);
Description:
Returns the next integer not less than x, and the fractional part of X is rounded off. The type returned by
Floor () is still float.
Example:
Copy the Code code as follows:
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 (-5.9))
?>
Output:
Copy the Code code as follows:
0
0
5
5
-6
-6
Round
Definition and usage
The round () function rounds a floating-point number.
Copy the Code code as follows:
Round (X,PREC);
which
X (optional) specifies the number to round.
PREC (optional) specifies the number of digits after the decimal point.
Description
Returns the result of rounding x according to the specified precision Prec (the number of digits after the decimal point).
Prec can also be negative or 0 (the default value).
Example:
Copy the Code code as follows:
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:
Copy the Code code as follows:
10
12
1
0
-1
-0
http://www.bkjia.com/PHPjc/313677.html www.bkjia.com true http://www.bkjia.com/PHPjc/313677.html techarticle A ceil is a function that is rounded up to get a value; the floor is a function that gets a value out of the decimal place, and round is a function that is used to round up ceil definition and usage: the Ceil () function goes up ...