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.
TheMath.ceil() static method always rounds up and returns the smallest integer greater than or equal to a given number.
In this article
Try it
console.log(Math.ceil(0.95));// Expected output: 1console.log(Math.ceil(4));// Expected output: 4console.log(Math.ceil(7.004));// Expected output: 8console.log(Math.ceil(-7.004));// Expected output: -7Syntax
js
Math.ceil(x)Parameters
xA number.
Return value
The smallest integer greater than or equal tox. It's the same value as-Math.floor(-x).
Description
Becauseceil() is a static method ofMath, you always use it asMath.ceil(), rather than as a method of aMath object you created (Math is not a constructor).
Examples
>Using Math.ceil()
js
Math.ceil(-Infinity); // -InfinityMath.ceil(-7.004); // -7Math.ceil(-4); // -4Math.ceil(-0.95); // -0Math.ceil(-0); // -0Math.ceil(0); // 0Math.ceil(0.95); // 1Math.ceil(4); // 4Math.ceil(7.004); // 8Math.ceil(Infinity); // InfinitySpecifications
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-math.ceil> |