Math.ceil()

Rounds a number up to the next largest integer.

Since ES1 Spec ↗

Syntax

Math.ceil(x)

Parameters

NameTypeRequiredDescription
x number Yes The number to round up.

Returns

number — The smallest integer greater than or equal to x.

Examples

console.log(Math.ceil(4.1), Math.ceil(4.0));
Output
5 4
console.log(Math.ceil(-4.7));
Output
-4

Notes

Rounds toward positive infinity, so `Math.ceil(-4.7)` is -4. Returns a number even if the result is integral. Contrast with `floor` and `trunc`.

Browser & runtime support

EnvironmentSince version
chrome 1.0
firefox 1.0
safari 1.0
edge 12
node 0.10

See also