rint (JavaScript)

Rounds a number to the nearest integer, with 0.5 rounded to the even integer.

Returns the double value that is closest in value to a and is equal to a mathematical integer. If two double values that are mathematical integers are equally close to the value of the argument, the result is the integer value that is even. Special cases are the following:
  • If the argument value is already equal to a mathematical integer, then the result is the same as the argument.
  • If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.

Defined in

Math (JavaScript)

Syntax

rint(value:double) : double
Parameter Description
value A number. See below for special cases.
Return value Description
double The number rounded to the nearest integer, or to the nearest even integer if the fraction is 0.5.

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.

Examples

This edit box onblur event rounds the value of a numeric field.
sessionScope.n = Math.rint(sessionScope.n)