Math.round() Round to nearest
Last updated: 2026-09-09
Math.round() Round to nearest
Math.round rounds to the nearest integer; .5 rounds up.
| Category | Math |
|---|---|
| ES version | ES1 |
📝 Syntax
Math.round(number);
⚙️ Parameters
| number | The number. |
|---|
Returns:The nearest 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
5
5
-4
ℹ️ info Math.round(-4.5) is -4 — .5 always rounds toward +infinity.
💡 Tip Keep N decimals: Math.round(num * 10**N) / 10**N.
🌐 Browser support
| Browser | |||||
|---|---|---|---|---|---|
| Math.round() | ✓ 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.round(-4.5) -4?
A.5 always rounds toward +infinity.
Qround vs toFixed?
Around gives integer; toFixed gives string with N decimals.
QHow to do banker's rounding?
ANot built-in; implement manually or use a library.