y=round(x)y = \operatorname{round}(x)

Graph of the Rounding Function y=round(x)y = \operatorname{round}(x)

y=round(x)y = \operatorname{round}(x) rounds xx to the nearest integer. If the fractional part is below 0.50.5 it rounds down, and above 0.50.5 it rounds up.

  • round(2.3)=2\operatorname{round}(2.3) = 2
  • round(2.6)=3\operatorname{round}(2.6) = 3
  • round(1.2)=1\operatorname{round}(-1.2) = -1

Domain and range. The domain is all real numbers and the range is all integers. The graph is a staircase of horizontal segments of width 11, each centered on an integer. For example, the value is 00 on 0.5<x<0.5-0.5 < x < 0.5 and 11 on 0.5<x<1.50.5 < x < 1.5.

Discontinuities and jumps. The function is discontinuous at the half-integers x=n+0.5x = n + 0.5, where the value jumps up by 11. How these exact midpoints are rounded is fixed by a convention. The most common 'round half up' rule gives:

  • round(0.5)=1\operatorname{round}(0.5) = 1
  • round(2.5)=3\operatorname{round}(2.5) = 3

In statistics and accounting, round half to even (banker's rounding) is often used to reduce bias, and the treatment of negatives and midpoints varies between implementations.

Symmetry. Away from the half-integers, round(x)=round(x)\operatorname{round}(-x) = -\operatorname{round}(x), so the function is essentially odd (point-symmetric about the origin). Only at the midpoints can the tie-breaking rule spoil this symmetry.

Relation to other functions. Under the round-half-up rule it can be written with the floor function:

round(x)=x+0.5\operatorname{round}(x) = \lfloor x + 0.5 \rfloor

So rounding is a sibling of the floor and ceiling functions, choosing whichever of x\lfloor x \rfloor and x\lceil x \rceil is closer to xx.

Applications. Rounding is used wherever continuous values must be reduced to convenient integers: displaying amounts of money, matching the number of digits of a measurement, and quantizing digital signals.