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 that is used for rounding.
Ceil
Definition and Usage:
The Ceil () function rounds up to the nearest integer.
[PHP]
Ceil (x);
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:
[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);
?>
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:
[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);
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:
[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 (-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 (-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);
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:
[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
http://www.bkjia.com/PHPjc/477158.html www.bkjia.com true http://www.bkjia.com/PHPjc/477158.html techarticle A ceil is a function that gets a value upward, and the floor is a function that gets a value out of the decimal place; Round is a function that is used for rounding. Ceil definition and Usage: ceil () function up ...