ceil (JavaScript)

Rounds a number to an integer by truncating the fraction and adding 1.

Defined in

Math (JavaScript)

Syntax

ceil(value:double) : double
Parameter Description
value A number. See below for special cases.
Return value Description
double The number truncated to an integer, plus 1.

Usage

Special cases are as follows:
  • Rounding NaN results in NaN.
  • Rounding +Infinity results in positive infinity.
  • Rounding -Infinity results in negative infinity.
  • Rounding Number.MIN_VALUE or a lesser number results in 1.
  • Rounding Number.MAX_VALUE or a greater number results in the maximum numeric value.

Math.ceil(x) equals -Math.floor(-x).

Examples

This edit box onblur event rounds the value of a numeric field by truncating the fraction and adding 1.
sessionScope.n = Math.ceil(sessionScope.n)