MOCKSTACKS
EN  # How to round a double value in Javascript?

If the floating-point number is above or equal to x.5 - it's rounded up to the nearest integer. If the floating-point number is below x.5, it's rounded down to the nearest integer:

``````Math.round(24.49); // 24
Math.round('29.5'); // 30
Math.round(72); // 72
Math.round(-40.51); // -41``````

The Math.floor() method is used to return the nearest whole integer that is less than or equal to a specified value. In layman's terms, the floor() method rounds a number down and returns an integer result:

``````Math.floor(75.95); //  75
Math.floor(75.05); //  75
Math.floor(4); //   4
Math.floor('-65.05'); // -66
Math.floor(-65.95); // -66``````

## Conclusion

In this page (written and validated by ) you learned about . What's Next? If you are interested in completing Javascript tutorial, we encourage you simply to start here: Javascript Tutorial.

Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue: mockstacks@gmail.com.