[Chapter 21] Reference: Math.floor()
Author: David Flanagan
Date: Fri Aug 29 11:17:45 1997

#

| Chapter 21 JavaScript Reference |

# Math.floor() Function

## Name

Math.floor() Function---round a number down

## Availability

Navigator 2.0, Internet Explorer 3.0

## Synopsis

    Math.floor(x)

### Arguments

`x`

  Any numeric value or expression.

### Returns

The closest integer less than or equal to `x`.

## Description

`Math.floor()` computes the floor function--i.e., it returns the nearest integer value that is less than or equal to the function argument. `Math.floor()` rounds a floating-point value down to the closest integer. This differs from `Math.round()` which rounds up or down to the nearest integer. Also note that `Math.floor()` rounds negative numbers to be more negative, not closer to zero.

## Example

    a = Math.floor(1.99);  // result is 1.0
    b = Math.floor(1.01);  // result is 1.0
    c = Math.floor(1.0);   // result is 1.0
    d = Math.floor(-1.01);  // result is -2.0

## See Also

"Math", "Math.ceil()", "Math.round()"

Math.exp() |  | Math.LN10