PHP | ceil( ) Function
We have often used the ceiling function in mathematical problems to round up a decimal number to next greater integral value. PHP provides us with a built-in function ceil() to perform such operation. The ceil() function is a built-in function in PHP and is used to round a number to the nearest greater integer.
Syntax:
float ceil(value)
Parameters: The ceil() function accepts a single parameter value which reperesents the number which you want to round up to the nearest greater integer.
Return Value: The return type of the ceil() function is float as shown in the syntax. It returns the number which represents the value rounded up to the next highest integer.
Examples:
Input : ceil(0.70) Output : 1 Input : ceil(-4.1) Output : -4 Input : ceil(6) Output : 6
Below programs illustrate the ceil() function in PHP:
- When a positive number with decimal places is passed as a parameter:
<?phpecho (ceil(0.70));?>chevron_rightfilter_noneOutput:
1
- When a negative number with decimal places is passed as a parameter:
<?phpecho (ceil(-4.1));?>chevron_rightfilter_noneOutput:
-4
- When a number with no decimal places is passed as a parameter:
<?phpecho (ceil(6));?>chevron_rightfilter_noneOutput:
6
Reference:
http://php.net/manual/en/function.ceil.php
Recommended Posts:
- p5.js | ceil() function
- PHP Math Functions (abs, pi, deg2rad, rad2deg, fmod, floor, ceil, round, is_finite, is_infinite)
- How to call a function that return another function in JavaScript ?
- How to get the function name from within that function using JavaScript ?
- D3.js | d3.set.add() Function
- PHP | abs( ) Function
- PHP | sin( ) Function
- PHP | cos( ) Function
- CSS | hsl() Function
- PHP | dir() Function
- p5.js | nfs() Function
- p5.js | nfp() Function
- p5.js | nfc() function
- CSS | rgb() Function
- D3.js | d3.rgb() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



