The JavaScript 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 parameters as mentioned above and described below:
- Value: It is the value that 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 is an example of the Math ceil() Method.
Example 1: In this example, we will get the round-off value of 0.89.
javascript
console.log( "Result : " + Math.ceil(.89)); |
Result : 1
Example 2: When a negative number is passed as a parameter.
javascript
console.log( "Result : " + Math.ceil(-89.02)); |
Result : -89
Example 3: When zero is passed as a parameter.
javascript
console.log( "Result : " + Math.ceil(0)); |
Result : 0
We have a complete list of Javascript Math Objects methods, to check those please go through this Javascript Math Object Complete reference article.
Supported Browsers:
- Google Chrome
- Firefox
- Opera
- Safari