A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/javascript-math-ceil-method/ below:

JavaScript Math ceil() Method - GeeksforGeeks

JavaScript Math ceil() Method

Last Updated : 15 Jul, 2024

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:

Return Value:

The Math.ceil() method returns the smallest integer greater than or equal to the given number.

Example 1: In this example, we will get the round-off value of 0.89.

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

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

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

Example 3: When zero is passed as a parameter.

javascript
console.log("Result : " + Math.ceil(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: JavaScript Math ceil() Method - FAQs What does the Math.ceil() method do in JavaScript?

The Math.ceil() method rounds a number up to the nearest integer greater than or equal to the given number.

Can Math.ceil() handle negative numbers?

Yes, Math.ceil() can handle negative numbers. It rounds negative numbers up towards zero to the nearest integer.

What is the most common use of the Math.ceil() method?

Most Common Use Cases:

Does Math.ceil() work with very large or very small numbers?

Yes, Math.ceil() works with very large or very small numbers, rounding them up to the nearest integer within the limits of JavaScript's number precision.

How does Math.ceil() handle numbers with a fractional part of 0?

If the number has a fractional part of 0 (i.e., it is already an integer), Math.ceil() returns the number unchanged.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4