JavaScript Math.round( ) function Last Updated : 22 May, 2023 Comments Improve Suggest changes Like Article Like Report JavaScript Math.round( ) function is used to round the number passed as a parameter to its nearest integer. Syntax: Math.round(value) Parameters: value: The number to be rounded to its nearest integer. Example 1: Rounding Off a number to its nearest integer To round off a number to its nearest integer, the math.round() function should be implemented in the following way: JavaScript let round = Math.round(5.8); console.log("Number after rounding : " + round); Output: Number after rounding : 6 Example 2: Rounding Off a negative number to its nearest integer The Math.round() function itself rounds off a negative number when passed as a parameter to it. To round off a negative number to its nearest integer, the Math.round() function should be implemented in the following way: JavaScript let round = Math.round(-5.8); console.log("Number after rounding : " + round); Output: Number after rounding : -6 Example 3: Math.round() function, when a parameter has ".5" as a decimal Below program shows the result of Math.round() function when the parameter has ".5" as a decimal. JavaScript let round = Math.round(-12.5); console.log("Number after rounding : " + round); let round2 = Math.round(12.51); console.log("Number after rounding : " + round2); Output: Number after rounding : -12 Number after rounding : 13 We have a complete list of Javascript Math Objects methods, to check those please go through this Javascript Math Object Complete reference article. Supported Browsers: Chrome 1 and aboveEdge 12 and aboveFirefox 1 and aboveInternet Explorer 3 and aboveOpera 3 and aboveSafari 1 and above We have a Cheat Sheet on Javascript where we covered all the important topics of Javascript to check those please go through Javascript Cheat Sheet-A Basic guide to JavaScript. Comment More infoAdvertise with us Next Article JavaScript Math.round( ) function A AyushSaxena Follow Improve Article Tags : JavaScript Web Technologies javascript-math Similar Reads Less.js Math round() Function Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. It is an extension to normal CSS which basically enhances the abilities of normal CSS and gives superpowers to it. LESS.js provides the built-in Math function that 3 min read JavaScript Math round() Method The JavaScript Math.round() method rounds a number to the nearest integer. It rounds up for decimal values of 0.5 and higher, and down otherwise.Syntax:Math.round(value);Parameters:value: It is the number that you want to round off.Return Value:The Math.round() method returns the value of the given 2 min read p5.js round() function The round() function in p5.js is used to calculate the round value of a number. It calculates the integer closest to the number. Syntax round(number) Parameters: The function accepts only one parameter as mentioned above and described below: number : This parameter stores the number to compute. Belo 1 min read Floating point number precision in JavaScript The representation of floating points in JavaScript follows the IEEE-754 format. It is a double-precision format where 64 bits are allocated for every floating point. The displaying of these floating values could be handled using these methods: Table of Content Using toFixed() MethodUsing toPrecisio 2 min read How to Format a Float in JavaScript? Formatting a float number means rounding off a number up to a given number of decimal places. Below are the approaches to format a float in JavaScript: Table of ContentUsing Math.ceil() methodUsing toFixed() methodUsing Math.round() methodUsing Math.floor() MethodUsing float.toExponential() methodUs 3 min read Like