JavaScript Math.ceil() Method
The Math.ceil() static method rounds a number up to the next whole number.
Description
The Math.ceil() static method always rounds up to the next largest integer. Whole numbers are returned unchanged. A common use is working out how many pages or boxes you need: Math.ceil(items / perPage).
For negative numbers, rounding up means moving towards zero, so Math.ceil(-4.7) is -4. To round up to a number of decimal places, scale first: Math.ceil(x * 100) / 100, keeping in mind that floating point values can make that slightly off at the edges.
Typical uses are working out how many pages, rows or containers are needed to hold a number of items, where any remainder needs one more. Like every member of Math, it's called on the Math object itself rather than on a number, and it only works with the Number type: passing a BigInt throws a TypeError.
Syntax
Math.ceil(x)Parameters
- xA number.
Return Value
The smallest integer greater than or equal to x.
Example
Browser Support
The following information will show you the current browser support for the Math.ceil() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





