Math Ceil function of Javascript returns the nearest greater value to the specified number. Math Ceil Function means the ceiling value i.e. upper value for the specified value. Math.ceil(x) function returns the upper nearest value for the specified number. Math.ceil function rounds off the specified number similar to the Math.round function as we discussed in the previous tutorial about Javascript Math Round Function. If round off process of Math.ceil function gets the precision point value greater than 0 then Math.ceil function return the number 1 greater than the number passed to it. Javascript Math Ceil function also returns the integer value by rounding of the precision point values resulting to its significant integer value.

Syntax for Javascript Math Ceil Function

Math.ceil(x);

Math.ceil function accepts value as number and returns the upper nearest integer value for it.

Examples of Javascript Math Ceil Function

document.write(Math.ceil(0.51) + "<br />");

document.write(Math.ceil(2) + "<br />");

document.write(Math.ceil(2.1) + "<br />");

document.write(Math.ceil(2.84) + "<br />");

document.write(Math.ceil(-2.44) + "<br />");

document.write(Math.ceil(-6.44) + "<br />");

document.write(Math.ceil(-6.94) + "<br />");

// Output
// 1
// 2
// 3
// 3
// -2
// -6
// -6

Continue to next tutorial: Javascript Math Floor Function to learn how to get the nearest smaller value to the specified number.

Recent JavaScript Tutorials

Javascript FSO ShortPath property

Javascript FileSystemObject (FSO) provides a ShortPath property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Path Property

Javascript FileSystemObject (FSO) provides the Path property that can be accessed through the file object or folder object returned by the GetFile or GelFolder method

Javascript FSO Type property

Javascript FileSystemObject (FSO) provides a Type property that can be accessed through file object or folder object returned by the GetFile or GetFolder method

Javascript FSO ShortName property

Javascript FileSystemObject (FSO) provides a ShortName property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Name Property

Javascript FileSystemObject (FSO) provides a Name property that can be accessed using file object or folder object.