Name
Math.round( ) — round to the nearest integer
Availability
JavaScript 1.0; JScript 1.0; ECMAScript v1
Synopsis
Math.round(x
)
Arguments
-
x
Any number.
Returns
The integer closest to x
.
Description
Math.round( )
rounds its argument up or down to
the nearest integer. It rounds .5 up. For example, it rounds 2.5 to 3
and rounds -2.5 to -2.
Get JavaScript: The Definitive Guide, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.