ceil

Returns the smallest integer greater than or equal to a number.

Applies to

Math

Syntax

ceil(x)

Parameters

x

A number.

Description

ceil is a static method of Math. As a result, you always use it as Math.ceil(), rather than as a method of a Math object you create.

Example

The following function returns the ceil value of the variable x:

function getCeil(x) {
      return Math.ceil(x)
}

If you pass 45.95 to getCeil, it returns 46; if you pass -45.95, it returns -45.

See also

Math:floor