JavaScript: The Definitive Guide

24.121. Math.round( ): round to the nearest integer

ECMAScript v1

24.121.1. Synopsis

Math.round(x)

24.121.1.1. Arguments

x

Any number.

24.121.1.2. Returns

The integer closest to x.

24.121.2. 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.

Категории