Math.floor() Round down
Last updated: 2026-09-09
Math.floor() Round down
Math.floor rounds down to the largest integer <= the given number.
| Category | Math |
|---|---|
| ES version | ES1 |
📝 Syntax
Math.floor(number);
⚙️ Parameters
| number | The number. |
|---|
Returns:The rounded-down integer.
Mutates the original:No (returns a new value)
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
4
4
4
-5
💡 Tip Random integer: Math.floor(Math.random() * max).
ℹ️ info Math.floor(-4.2) is -5 — toward negative infinity.
🌐 Browser support
| Browser | |||||
|---|---|---|---|---|---|
| Math.floor() | ✓ v1 | ✓ v12 | ✓ v1 | ✓ v1 | ✓ v1 |
| Supported by all modern browsers | |||||
🏷️ Related Items
💡 Related Cases
More case studies coming soon — check back later.
📚 Related Tutorials
❓ FAQ
QWhy is Math.floor(-4.2) -5?
AFloor goes toward -infinity — -5 < -4.2.
QHow to generate random integers?
AMath.floor(Math.random() * max).
Qfloor vs trunc?
Afloor goes to -infinity; trunc goes to zero. Same for positives.