Skip to content
Latest: JSX in React explained clearly without any framework

Math.ceil() Method in JS – How to Round Up Numbers

Whenever you invoke Math.ceil(), the method rounds up its argument to the nearest integer.

Syntax of the Math.ceil() Method

Math.ceil() accepts only one argument. Here is the syntax:

Math.ceil(value);

The value argument represents the number you wish to round up to the nearest integer.

Examples

Below are examples of the Math.ceil() method.

Round up 9 to the nearest integer

Math.ceil(9);
// The invocation above will return: 9

Try it on StackBlitz

Round up 9.999 to the nearest integer

Math.ceil(9.999);
// The invocation above will return: 10

Try it on StackBlitz

Round up -9.999 to the nearest integer

Math.ceil(-9.999);
// The invocation above will return: -9

Try it on StackBlitz

The snippet above returned -9 because -9 is the integer directly above -9.999 on the number line. In other words, -9 is greater than -9.999. But -10 is less than -9.999.

Round up 0.91 to the nearest integer

Math.ceil(0.91);
// The invocation above will return: 1

Try it on StackBlitz

Round up 0.01 to the nearest integer

Math.ceil(0.01);
// The invocation above will return: 1

Try it on StackBlitz

Round up 0 to the nearest integer

Math.ceil(0);
// The invocation above will return: 0

Try it on StackBlitz