floor (JavaScript)

Rounds a number to an integer by truncating the fraction.

Defined in

Math (JavaScript)

Syntax

floor(value:double) : double
Parameter Description
value A number. See the rest of the topic for special cases.
Return value Description
double The number truncated to an integer.

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 zero.
  • Rounding Number.MAX_VALUE or a greater number results in the maximum numeric value.

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

Examples

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