Math.ceil()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

The Math.ceil() static method always rounds up and returns the smallest integer greater than or equal to a given number.

Try it

Syntax

js
Math.ceil(x)

Parameters

x

A number.

Return value

The smallest integer greater than or equal to x. It's the same value as -Math.floor(-x).

Description

Because ceil() is a static method of Math, you always use it as Math.ceil(), rather than as a method of a Math object you created (Math is not a constructor).

Examples

Using Math.ceil()

js
Math.ceil(-Infinity); // -Infinity
Math.ceil(-7.004); // -7
Math.ceil(-4); // -4
Math.ceil(-0.95); // -0
Math.ceil(-0); // -0
Math.ceil(0); // 0
Math.ceil(0.95); // 1
Math.ceil(4); // 4
Math.ceil(7.004); // 8
Math.ceil(Infinity); // Infinity

Specifications

Specification
ECMAScript Language Specification
# sec-math.ceil

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
ceil

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also