rounds to the nearest integer1. A fractional part below is discarded and one above is rounded up.
The domain is all real numbers and the range is the set of all integers. The graph is a staircase of horizontal segments of width , each sitting over an interval centered on an integer.
| Interval | Value |
|---|---|
For the floor and ceiling functions the breaks between steps fell on the integers; for rounding they fall on the half-integers. Because each step is centered on its integer, the error of the rounding is as small as it can be.
The function is discontinuous at the half-integers , the exact midpoints, where the value jumps by . Which way those midpoints go is fixed by convention.
| Convention | |||
|---|---|---|---|
| Round half up | |||
| Round half to even, or banker's rounding |
Statistics and accounting often use rounding to even, to avoid a bias toward rounding up. Implementations differ over negative numbers and midpoints, so it is safest to check before relying on one.
Away from the half-integers holds, so the graph has broadly point symmetry about the origin. Only at the midpoints can the convention break that symmetry.
Under the round-half-up convention it can be written with the floor function.
Rounding is thus a sibling of the floor and ceiling functions: it amounts to choosing whichever of and lies closer to .
It is used wherever a continuous value has to be rounded to an integer that is easier to handle.