Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The Math.floor() static method always rounds down and returns the largest integer less than or equal to a given number.
A number.
The largest integer smaller than or equal to x. It's the same value as -Math.ceil(-x).
Because floor() is a static method of Math, you always use it as Math.floor(), rather than as a method of a Math object you created (Math is not a constructor).
In this example, we implement a method called decimalAdjust() that is an enhancement method of Math.floor(), Math.ceil(), and Math.round(). While the three Math functions always adjust the input to the units digit, decimalAdjust accepts an exp parameter that specifies the number of digits to the left of the decimal point to which the number should be adjusted. For example, -1 means it would leave one digit after the decimal point (as in "× 10-1"). In addition, it allows you to select the means of adjustment — round, floor, or ceil — through the type parameter.
It does so by multiplying the number by a power of 10, then rounding the result to the nearest integer, then dividing by the power of 10. To better preserve precision, it takes advantage of Number's toString() method, which represents large or small numbers in scientific notation (like 6.02e23).
| ECMAScript® 2027 Language Specification # sec-math.floor |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jul 10, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.