What is Math.ceil() in JavaScript?

Math is a built-in object in JavaScript that contains different methods and properties used to perform mathematical operations. It contains the ceil() function, which is used to compute the smallest integer greater than or equal to a specified number.

Syntax

Math.ceil(param);

Parameter

  • param: This is the input value of the Number type for which we want to find the ceil().

Number in JavaScript is a 64-bit double-precision value which is the same as double in C# or Java.

Return value

  • Number: This rounds the input number and returns the next smallest integer greater than or equal to the input parameter param. It is of the Number type.

Example

console.log("ceil(-1) = " + Math.ceil(-1));
console.log("ceil(1) = " + Math.ceil(1));
console.log("ceil(-10.54) = " + Math.ceil(-10.54));
console.log("ceil(10.54) = " + Math.ceil(10.54));
console.log("ceil(11.34) = " + Math.ceil(11.34));
console.log("ceil(-0.5) = " + Math.ceil(-0.5));

Free Resources