Returns the value of a number rounded to the nearest integer.
Math
round(x)
x
If the fractional portion of number is .5 or greater, the argument is rounded to the next highest integer. If the fractional portion of number is less than .5, the argument is rounded to the next lowest integer.
round is a static method of Math. As a result, you always use it as Math.round(), rather than as a method of a Math object you create.
//Displays the value 20 Console.Write("The rounded value is " + Math.round(20.49)) //Displays the value 21 Console.Write("The rounded value is " + Math.round(20.5)) //Displays the value -20 Console.Write("The rounded value is " + Math.round(-20.5)) //Displays the value -21 Console.Write("The rounded value is " + Math.round(-20.51))