Roundoff error

For the acrobatic movement, roundoff, see Roundoff.

A round-off error, also called rounding error, is the difference between the calculated approximation of a number and its exact mathematical value. Numerical analysis specifically tries to estimate this error when using approximation equations and/or algorithms, especially when using finitely many digits to represent real numbers (which in theory have infinitely many digits). This is a form of quantization error.

When a sequence of calculations subject to rounding error is made, errors may accumulate, sometimes dominating the calculation. Cases where significant error accumulates are known as ill-conditioned.

Representation error

The error introduced by attempting to represent a number using a finite string of digits is called representation error. Here are some examples of representation error in decimal representations:

Notation Representation Approximation Error
1/7 0.142 857 0.142 857 0.000 000 142 857
ln 2 0.693 147 180 559 945 309 41...   0.693 147 0.000 000 180 559 945 309 41...
log10 2 0.301 029 995 663 981 195 21...   0.3010 0.000 029 995 663 981 195 21...
2  1.259 921 049 894 873 164 76...   1.25992 0.000 001 049 894 873 164 76...
2  1.414 213 562 373 095 048 80...   1.41421 0.000 003 562 373 095 048 80...
e 2.718 281 828 459 045 235 36...   2.718 281 828 459 045   0.000 000 000 000 000 235 36...
π 3.141 592 653 589 793 238 46...   3.141 592 653 589 793 0.000 000 000 000 000 238 46...

Increasing the number of digits allowed in a representation reduces the magnitude of possible round-off errors, but any representation limited to finitely many digits will still cause some degree of round-off error for uncountably many real numbers. Additional digits used for intermediary steps of a calculation are known as guard digits.

Rounding multiple times can cause error to accumulate. For example, if 9.945309 is rounded to two decimal places (9.95), then rounded again to one decimal place (10.0), the total error is 0.054691. Rounding 9.945309 to one decimal place (9.9) in a single step introduces less error (0.045309). This commonly occurs when performing arithmetic operations (See Loss of Significance).

Standardized Rounding Methods

There are five standard ways of performing the rounding in IEEE standard arithmetic:

• Truncation: Keep the desired number of digits unchanged, removing all less-significant digits; also called rounding toward zero.
0.142857 ≈ 0.142 (All digits less significant than the third removed).
• Round to Nearest: Round to the nearest valid representation. Break ties by rounding either to an even digit (default), or away from zero.
• Round to −∞: Round to a value less than or equal to the original number. If the original number is positive, this is equivalent to truncation.
• Round to +∞: Round to a value greater than or equal to the original number. If the original number is negative, this is equivalent to truncation.

Breaking ties by rounding towards an even value preserves the expected value of the original number and treats positive and negative numbers symmetrically, and also slightly more often supplies an even number that is less likely than an odd number to cause a rounding decision in later computations if those are similar to the computation that resulted in falling at just that midpoint (e.g., if it is being fed back into an iteration). It is common practice in meteorology to round published temperatures towards an odd value in such situations; this has all the same properties apart from the last.