Link Search Menu Expand Document

round

Explanation Rounds to the specified digit.
If the number of digits is omitted, the number after the decimal point is rounded off.

Rounding of the round function (when the number of digits = 0) will be Value + the maximum (positive direction) of integers less than or equal to 0.5

*Added since Version 2.0.0*
Call format var r = round( arg, n )
Return value Returns the value rounded to the specified number of digits.
Arguments Number arg Original number
Number n Position of the digit to be rounded
Exception None
Example of use
print(round(12345.678, -2)); /* 12300となる */
print(round(12345.678));     /* 12346となる */
print(round(12345.678, 2));  /* 12345.68となる */
 
print(round(0.49));  /* 0となる */
print(round(0.50));  /* 1となる */
print(round(0.51));  /* 1となる */
print(round(-0.49)); /* 0となる */
print(round(-0.50)); /* 0となる */
print(round(-0.51)); /* -1となる */
Related item rounddown, roundup, roundm methods