Below is the example of the Math ceil() Method.
- Example:
<script type="text/javascript">document.write("Result : "+ Math.ceil(.89));</script>chevron_rightfilter_none - Output:
Result : 1
The Math.ceil method is used to return the smallest integer greater than or equal to a given number. The ceil() is always used as Math.ceil() since it is a static method of Math.
Syntax:
Math.ceil(value)
Parameters: This method accepts single parameter asmentioned above and described below:
- Value: It is the value which is to be tested for Math.ceil.
Return Value: The Math.ceil() method returns the smallest integer greater than or equal to the given number.
Below examples illustrate the Math ceil() method in JavaScript:
Input : Math.ceil(.89) Output: 1
Input : Math.ceil(-89.02) Output : -89
Input : Math.ceil(0) Output : 0
More codes for the above method are as follows:
Program 1: When a negative number is passed as a parameter.
<script type="text/javascript"> document.write("Result : " + Math.ceil(-89.02)); </script> |
Output:
Result : -89
Program 2: When zero is passed as a parameter.
<script type="text/javascript"> document.write("Result : " + Math.ceil(0)); </script> |
Output:
Result : 0
Supported Browsers:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- JavaScript | Math.ceil( ) function
- PHP Math Functions (abs, pi, deg2rad, rad2deg, fmod, floor, ceil, round, is_finite, is_infinite)
- JavaScript Math tan( ) Method
- JavaScript Math cos( ) Method
- JavaScript Math log( ) Method
- JavaScript Math exp( ) Method
- JavaScript Math max() Method
- JavaScript Math pow( ) Method
- JavaScript Math abs( ) Method
- JavaScript Math min( ) Method
- JavaScript Math sin( ) Method
- JavaScript Math floor() Method
- JavaScript Math cbrt() Method
- JavaScript Math acosh() Method
- JavaScript Math sqrt( ) Method
- JavaScript Math atan2( ) Method
- JavaScript Math tanh() Method
- JavaScript Math acos( ) Method
- JavaScript Math asin( ) Method
- JavaScript Math atan( ) Method
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.


