Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

math.round()

The Math.round()  function 
returns the value of a number rounded to the nearest integer.

Math.round(x)
// If x = 0.6 it gives you 1; if x = 2.5 it gives you 3; 
// if x=2.49999 it gives you 2.  

Math.round( 20.49); //  20
Math.round( 20.5 ); //  21
Math.round( 42   ); //  42
Math.round(-20.5 ); // -20
Math.round(-20.51); // -21
Source by livecodestream.dev #
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
6+9 =