Open In App

JavaScript Math ceil() Method

Last Updated : 01 Aug, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

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));


Output

Result : 1

Example 2: When a negative number is passed as a parameter.

javascript




console.log("Result : " + Math.ceil(-89.02));


Output

Result : -89

Example 3: When zero is passed as a parameter.

javascript




console.log("Result : " + Math.ceil(0));


Output

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


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads