floor Function

Top  Previous  Next

Rounds a number downward to its nearest integer.

Syntax

Math.floor(number)

Arguments

numberA number.

Return Value

A number which represents the nearest integer when rounding downwards.

Examples

Math.floor(0.1);          // Returns 0

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

Math.floor(-8.9);         // Returns -9

Math.floor(-8.1);         // Returns -9

See also

Math.ceil