Rounds the provided real value to the nearest integer. Values with a fractional part of 0.5 or greater are rounded away from zero.
Examples
Produces 3.
Produces 4.
Produces -3.
REM Compare ROUND with INT (truncate) and CEIL (round up)
x# = -1.7
PRINT "ROUND("; x#; ") = "; ROUND(x#) ' -2
PRINT "INT("; x#; ") = "; INT(x#) ' -1 (towards zero)
PRINT "CEIL("; x#; ") = "; CEIL(x#) ' -1 (towards +infinity)
Notes
- Returns a 64-bit integer.
- Halfway cases (.5) always round away from zero:
- ROUND(2.5) → 3
- ROUND(-2.5) → -3
- Differs from INT, which truncates towards zero, and from CEIL, which always rounds up.
See also: INT · CEIL