[Previous] [Contents] [Next]


Ceiling and Floor


The ceil( ) and floor( ) functions can return the integer value above and below a fractional value, respectively:

float ceil(float value)
float floor(float value)

The return type is a float because an integer may not be able to represent the result when a large value is passed as an argument. Consider the following examples:

echo ceil(27.3);   // prints 28
echo floor(27.3);  // prints 27

[Previous] [Contents] [Next]