JavaScript Math.ceil()
More "Try it Yourself" examples below.
Definition and Usage
The Math.ceil() method rounds a number UPWARDS to the nearest integer, and returns the result.
More Examples
let a = Math.ceil(0.60);
let b = Math.ceil(0.40);
let c = Math.ceil(5);
let d = Math.ceil(5.1);
let e = Math.ceil(-5.1);
let f = Math.ceil(-5.9);
Try it Yourself »
Browser Support
Math.ceil()
is an ECMAScript1 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |
Syntax
Math.ceil(x)
Parameters
Parameter | Description |
---|---|
x | Required. The number you want to round. |
Return Value
A number representing the nearest integer when rounding upwards. |