Math.round() (Function)

Rounds to the nearest integer value.

Availability:

ECMAScript edition - 2
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape Navigator - 2.0
Netscape Enterprise Server version - 2.0
Opera - 3.0
Property/method value type:Number primitive
JavaScript syntax:-Math.round(aValue)
Argument list:aValueA meaningful numeric value

This function returns the value that is closest to the argument and is a mathematical integer. It rounds the input value to the nearest integer value either rounding up or down as necessary.

If the input value is equidistant from two integer values, the result is rounded up towards positive infinity. If the argument is already an integer, the argument itself is returned.

Special boundary conditions that affect the results are:

ArgumentResult
+infinity+infinity
-0.5 < arg < 0.50
-infinity-infinity
00
NaNNaN

Note that Math.round(3.5) returns the value 4 while Math.round(-3.5) returns the value 3.

See also:Integer arithmetic, Integer-value-remainder, Math object, Math.ceil(), Math.floor(), Number(), Type conversion

Cross-references:

ECMA 262 edition 2 - section - 15.8.2.15

ECMA 262 edition 3 - section - 15.8.2.15