Link Search Menu Expand Document

Math.round methods

Explanation Find the value rounded to the nearest whole number.
Returns the integer closest to the value ( value + the largest (positive direction) of integers less than or equal to 0.5 )
Call format var v = Math.round (x)
Return value Returns an integer rounded to the nearest whole number.
Arguments Number x Value to round off to the nearest whole number
Exception None
Example of use
print (Math.round (0.49), "¥ n");   / * 0 * /
print (Math.round (0.50), "¥ n");   / * 1 * /
print (Math.round (0.51), "¥ n");   / * 1 * /
 
print (Math.round (-0.49), "¥ n"); / * 0 * /
print (Math.round (-0.50), "¥ n"); / * 0 * /
print (Math.round (-0.51), "¥ n"); / * -1 * /
Related item ceil , floor methods