Thursday, December 26, 2024
Google search engine
HomeLanguagesJavascriptJavaScript Math ceil() Method

JavaScript Math ceil() Method

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
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments