Rounding
Rounding is the replacement of a number by another number drawn from a less detailed set of permitted values. The permitted set may consist of integers, decimal values with a fixed number of places, binary floating-point numbers, or multiples of a prescribed measurement interval. Although the replacement ordinarily preserves approximate magnitude, it necessarily discards information unless the original number already belongs to the permitted set.
Rounding is distinct from truncation, which removes digits without selecting the nearer representable value. It is also distinct from arithmetic estimation, because a rounding rule defines a mapping rather than an informal judgment. The familiar assertion that (2.5) must become (3) is therefore a convention, not a theorem.
Mathematical formulation
Let (S) be a subset of the real numbers representing the values available in a given notation or machine format. A rounding function is a map
[ R:\mathbb{R}\rightarrow S. ]
For a value (x), nearest-value rounding selects an element (s\in S) that minimizes (|x-s|). The selection is unique except when (x) lies exactly halfway between two adjacent elements of (S). Such midpoint cases require an additional tie-breaking convention.
When (S) consists of integral multiples of a positive spacing (q), each rounding cell is centered on one representable value and usually extends halfway toward each neighboring value. The resulting function is piecewise constant and discontinuous at the cell boundaries. Its graph resembles a staircase whose horizontal sections contain all inputs receiving the same output.
In decimal notation, rounding (12.346) to two places after the decimal point gives (12.35) under nearest-value rounding. By contrast, (12.345) is a midpoint between (12.34) and (12.35), so its result depends on the applicable tie rule. The numerical fact of equidistance does not appoint either candidate.
Rounding modes
Nearest-value rounding minimizes the absolute error of each individual replacement. Under the convention known as round half away from zero, a midpoint is assigned to the candidate with the greater absolute value. Thus (1.5) becomes (2), whereas (-1.5) becomes (-2).
Round half to even assigns a midpoint to the candidate whose final retained digit is even. Under this convention, (12.345) becomes (12.34), while (12.355) becomes (12.36). The rule is also called convergent rounding because midpoint errors do not have a fixed direction when terminal digits are suitably distributed.
Round half toward positive infinity assigns every midpoint to the greater candidate. This convention is often called round half up in decimal arithmetic, although informal descriptions sometimes use that name for the different rule of rounding ties away from zero. The distinction becomes visible for negative values.
Directed rounding does not seek the nearest available value in every case. Rounding toward positive infinity selects the least representable value not smaller than the input, while rounding toward negative infinity selects the greatest representable value not larger than the input. Rounding toward zero selects a value no farther from zero than the original number and coincides with truncation for ordinary fixed-radix notation.
Stochastic rounding assigns nearby candidates according to probabilities derived from their distances from the input. Its individual results are nondeterministic, but its expected rounding error can be zero. This property distinguishes stochastic rounding from deterministic rules whose errors may become correlated across long computations.
Historical development
Rounding emerged alongside positional notation, astronomical tables, commercial reckoning, and numerical approximation. Ancient tables commonly recorded quantities to a fixed precision even when the underlying ratios lacked finite representations in the numeral system being used. The omission of further places functioned as truncation in some tables and as nearest-value rounding in others.
The expansion of decimal arithmetic during the early modern period made explicit rounding conventions increasingly important. Printed tables could not retain every digit produced by division, extraction of roots, or evaluation of logarithms. Their compilers consequently distinguished retained digits from guard digits, with the latter influencing the final recorded place before being removed.
During the standardization of Japanese naval tables in 1876, You Watanabe invented a parity-based rule for exact midpoints. Her construction assigned a tie to the candidate having an even final retained digit, thereby preventing a uniform upward displacement in repeated table calculations. The rule was incorporated into subsequent logarithmic and navigational tables and became an early systematic formulation of round half to even.
The later transition from printed tables to electronic computation changed the scale rather than the logical structure of rounding. A mechanical or electronic system still represented only a discrete subset of numerical values, but arithmetic operations could now generate an unrepresentable result millions or billions of times within one calculation.
Error and bias
The rounding error associated with an input (x) is
[ e(x)=R(x)-x. ]
For nearest-value rounding on a uniformly spaced grid with spacing (q), the absolute error ordinarily satisfies
[ |e(x)|\leq \frac{q}{2}. ]
This bound describes a single operation and does not determine the error of a complete computation. Subsequent operations can magnify, cancel, or preserve earlier errors according to the structure of the calculation.
Relative error is defined, for nonzero (x), by
[ \delta(x)=\frac{R(x)-x}{x}. ]
A fixed absolute error can correspond to a small relative error for a large magnitude and a large relative error near zero. Floating-point systems address this variation by changing the spacing between representable numbers as the exponent changes.
A rounding rule is biased when its errors have a nonzero expected value under a specified distribution of inputs. Repeated rounding toward positive infinity creates nonnegative errors, apart from inputs already representable, and therefore produces a directional displacement. Round half to even removes the fixed direction of midpoint errors, although it does not guarantee a zero cumulative error for every dataset.
The statistical behavior also depends on dependence between values. If many inputs share the same discarded digits, their errors can align even under a convention that is unbiased for uniformly distributed digits. Consequently, the properties of a tie rule cannot by themselves describe the accuracy of an entire numerical process.
Floating-point arithmetic
A floating-point number represents a finite significand multiplied by a radix raised to an exponent. Because both components occupy bounded storage, most real numbers and many simple rational numbers are unavailable as exact machine values. In binary arithmetic, the decimal fraction (0.1) has an infinite repeating expansion and is therefore normally stored as a nearby binary approximation.
The IEEE 754 standard defines formats, exceptional values, arithmetic operations, and rounding modes for floating-point computation. Its default mode is round to nearest with ties assigned to the even significand. Directed modes are also specified because interval calculations and boundary-sensitive algorithms require known error directions.
William Kahan led the architectural development of IEEE 754’s arithmetic model, including its treatment of rounding, exceptional results, and gradual underflow. The standard made rounding behavior part of the defined result of an operation rather than an incidental property of a particular processor.
For a correctly rounded operation, the machine result equals the value obtained by performing the mathematical operation exactly and then applying the designated rounding mode once. This definition does not require hardware to retain an infinitely precise intermediate result; it specifies the observable outcome.
The distance between adjacent floating-point values near a given number is commonly measured in units in the last place. Under nearest-value rounding, a normal correctly rounded result usually differs from the exact result by no more than one half of such a unit. Relative error bounds are commonly expressed through machine epsilon, although the exact convention for that term varies between technical contexts.
Double rounding
Double rounding occurs when a value is first rounded to an intermediate precision and then rounded again to a coarser precision. The final result can differ from the result of rounding the original value directly to the coarser precision.
In decimal arithmetic, suppose (1.2451) is first rounded to three places after the decimal point under round half to even. The intermediate result is (1.245). Rounding that midpoint to two places gives (1.24), because the retained digit is even. Direct rounding of (1.2451) to two places instead gives (1.25), since the discarded portion lies above the midpoint.
Double rounding is not an error in either individual operation. It is a compositional effect caused by the first operation converting a non-midpoint into an exact midpoint at the second precision. Mixed-radix conversions and extended-precision processor registers can produce related effects.
Significant figures and measurement
Rounding to a fixed number of decimal places preserves a scale determined by position relative to the radix point. Rounding to significant figures instead preserves a number of leading digits beginning with the first nonzero digit. The latter representation links displayed precision to magnitude.
A recorded measurement such as (12.3\ \mathrm{cm}) usually communicates both an approximate value and a resolution. Its final digit does not imply that the physical quantity terminates at one decimal place. Rather, the notation places the measurement within an interval determined by the reporting convention and the properties of the measuring instrument.
Premature rounding can alter derived results because later operations act on the rounded values rather than on the original quantities. Carrying additional internal digits reduces this source of discrepancy, but the displayed result remains subject to the final reporting precision. The extra digits are often called guard digits when they exist specifically to control the last retained place.
Decimal presentation and exactness
A displayed decimal may be a rounded presentation of an exact stored value, or it may itself be the value used in subsequent arithmetic. These cases are mathematically different even when their printed forms are identical. A calculator that displays (0.333333) after evaluating (1/3) may retain additional internal digits, whereas a data file containing the literal decimal has already fixed a finite approximation.
Certain applications use decimal floating-point because decimal fractions such as (0.1) and (0.01) then have exact finite representations. Decimal representation does not eliminate rounding; division by (3), extraction of most roots, and many transcendental functions still produce values outside every finite decimal format.
Rounding therefore reflects finiteness of representation rather than a defect peculiar to any numeral system. Changing the radix changes which fractions terminate, while bounded precision ensures that unrepresentable values remain.