Favorites

JavaScript Math.round() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Math.round()
JavaScript Math Static methodThis method is supported by all modern browsers.
Updated 28th November 2026

The Math.round() static method rounds a number to the nearest whole number. Halves round up, towards positive infinity.

Description

The Math.round() static method returns the number rounded to the nearest integer. Values exactly halfway round towards positive infinity, so Math.round(2.5) is 3 but Math.round(-2.5) is -2.

To round to a number of decimal places, multiply first: Math.round(x * 100) / 100. For displaying a fixed number of decimals, toFixed() returns a padded string.

Floating point values can make rounding to decimal places look wrong, as with Math.round(1.005 * 100) / 100 giving 1, because 1.005 is stored as slightly less. For money, working in whole cents avoids most of these problems. Intl.NumberFormat rounds correctly for display.

Syntax

Math.round(x)

Parameters

  • xA number.

Return Value

x rounded to the nearest integer.

Example

console.log(Math.round(4.4), Math.round(4.5));
console.log(Math.round(-2.5));
console.log(Math.round(3.14159 * 100) / 100);

Browser Support

The following information will show you the current browser support for the Math.round() method. Hover over a browser icon to see the version that first introduced support for this method.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee