JavaScript Math.ceil() Method

You are Here:

JavaScript Math.ceil() Method

The Math.ceil() method returns a number representing the nearest integer which is greater than or equal to the given number.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var result = Math.ceil(4.2); document.write(result); </script> </body> </html>

Syntax

Math.ceil(x)

Parameter Values

ValueTypeExplanation
xRequiredSpecifies a number.

Return Values

ValueExplanation
NumberReturns a number representing the nearest integer which is greater than or equal to the given number.
0If null is passed as a value, i.e, Math.ceil(null).

More Examples

Example

HTML Online Editor
Math.ceil(null); // 0 Math.ceil(-4.2); // -4 Math.ceil(-4.6); // -4 Math.ceil(-4); // -4 Math.ceil(4); // 4 Math.ceil(4.2); // 5 Math.ceil(4.6); // 5

Reminder

Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author