round Function

Top  Previous  Next

Rounds a number to the nearest integer.

Syntax

Math.round(number)

Arguments

numberA number.        

Return Value

A number which represents the nearest integer of the argument.

Remarks

If the first digit after the comma is a number lower than 5, the number is rounded down, otherwise, the number is rounded up.

Examples

Math.round(0.1);          // Returns 0

Math.round(-0.1);         // Returns 0

Math.round(8.47);         // Returns 8

Math.round(8.57);         // Returns 9