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
NaNresults in NaN. - Rounding
+Infinityresults in positive infinity. - Rounding
-Infinityresults in negative infinity. - Rounding
Number.MIN_VALUEor a lesser number results in zero. - Rounding
Number.MAX_VALUEor a greater number results in the maximum numeric value.
Math.floor(x) equals -Math.ceil(-x).
Examples
This edit boxonblur event
rounds the value of a numeric field by truncating the fraction.sessionScope.n = Math.floor(sessionScope.n)