Rounding or rounding off is the process of adjusting a number to an approximate, more convenient value, often with a shorter or simpler representation. For example, replacing $23.4476 with $23.45, the fraction 312/937 with 1/3, or the expression √2 with 1.414.
Rounding is often done to obtain a value that is easier to report and communicate than the original. Rounding can also be important to oid misleadingly precise reporting of a computed number, measurement, or estimate; for example, a quantity that was computed as 123456 but is known to be accurate only to within a few hundred units is usually better stated as "about 123500".
On the other hand, rounding of exact numbers will introduce some round-off error in the reported result. Rounding is almost unoidable when reporting many computations – especially when dividing two numbers in integer or fixed-point arithmetic; when computing mathematical functions such as square roots, logarithms, and sines; or when using a floating-point representation with a fixed number of significant digits. In a sequence of calculations, these rounding errors generally accumulate, and in certain ill-conditioned cases they may make the result meaningless.
Accurate rounding of transcendental mathematical functions is difficult because the number of extra digits that need to be calculated to resolve whether to round up or down cannot be known in advance. This problem is known as "the table-maker's dilemma".
Rounding has many similarities to the quantization that occurs when physical quantities must be encoded by numbers or digital signals.
A wy equals sign (≈, approximately equal to) is sometimes used to indicate rounding of exact numbers, e.g. 9.98 ≈ 10. This sign was introduced by Alfred George Greenhill in 1892.[1]
Ideal characteristics of rounding methods include:
Rounding should be done by a function. This way, when the same input is rounded in different instances, the output is unchanged. Calculations done with rounding should be close to those done without rounding. As a result of (1) and (2), the output from rounding should be close to its input, often as close as possible by some metric. To be considered rounding, the range will be a subset of the domain, often discrete. A classical range is the integers, Z. Rounding should preserve symmetries that already exist between the domain and range. With finite precision (or a discrete domain), this translates to removing bias. A rounding method should he utility in computer science or human arithmetic where finite precision is used, and speed is a consideration.Because it is not usually possible for a method to satisfy all ideal characteristics, many different rounding methods exist.
As a general rule, rounding is idempotent;[2] i.e., once a number has been rounded, rounding it again to the same precision will not change its value. Rounding functions are also monotonic; i.e., rounding two numbers to the same absolute precision will not exchange their order (but may give the same value). In the general case of a discrete range, they are piecewise constant functions.
Types of rounding[edit]Typical rounding problems include:
Rounding problem Example input Result Rounding criterion Approximating an irrational number by a fraction π 22/7 1-digit-denominator Approximating a rational number by a fraction with smaller denominator 399 / 941 3 / 7 1-digit-denominator Approximating a fraction by a fractional decimal number 5 / 3 1.6667 4 decimal places Approximating a fractional decimal number by one with fewer digits 2.1784 2.18 2 decimal places Approximating a decimal integer by an integer with more trailing zeros 23217 23200 3 significant figures Approximating a large decimal integer using scientific notation 300999999 3.01 × 108 3 significant figures Approximating a value by a multiple of a specified amount 48.2 45 Multiple of 15 Approximating each of a finite set of real numbers by an integer so that the sum of the rounded numbers equals the rounded sum of the numbers[nb 1] { 3 12 , 4 12 , 5 12 } {\displaystyle {\bigl \{}{\tfrac {3}{12}},{\tfrac {4}{12}},{\tfrac {5}{12}}{\bigr \}}} {0, 0, 1} Sum of rounded elements equals rounded sum of elements Rounding to integer[edit]The most basic form of rounding is to replace an arbitrary number by an integer. All the following rounding modes are concrete implementations of an abstract single-argument "round()" procedure. These are true functions (with the exception of those that use randomness).
Directed rounding to an integer[edit]These four methods are called directed rounding to an integer, as the displacements from the original number x to the rounded value y are all directed toward or away from the same limiting value (0, +∞, or −∞). Directed rounding is used in interval arithmetic and is often required in financial calculations.
If x is positive, round-down is the same as round-toward-zero, and round-up is the same as round-away-from-zero. If x is negative, round-down is the same as round-away-from-zero, and round-up is the same as round-toward-zero. In any case, if x is an integer, y is just x.
Where many calculations are done in sequence, the choice of rounding method can he a very significant effect on the result. A famous instance involved a new index set up by the Vancouver Stock Exchange in 1982. It was initially set at 1000.000 (three decimal places of accuracy), and after 22 months had fallen to about 520, although the market appeared to be rising. The problem was caused by the index being recalculated thousands of times daily, and always being truncated (rounded down) to 3 decimal places, in such a way that the rounding errors accumulated. Recalculating the index for the same period using rounding to the nearest thousandth rather than truncation corrected the index value from 524.811 up to 1098.892.[3]
For the examples below, sgn(x) refers to the sign function applied to the original number, x.
Rounding down[edit]One may round down (or take the floor, or round toward negative infinity): y is the largest integer that does not exceed x.
y = f l o o r ( x ) = ⌊ x ⌋ = − ⌈ − x ⌉ {\displaystyle y=\mathrm {floor} (x)=\left\lfloor x\right\rfloor =-\left\lceil -x\right\rceil }For example, 23.7 gets rounded to 23, and −23.2 gets rounded to −24.
Rounding up[edit]One may also round up (or take the ceiling, or round toward positive infinity): y is the smallest integer that is not less than x.
y = ceil ( x ) = ⌈ x ⌉ = − ⌊ − x ⌋ {\displaystyle y=\operatorname {ceil} (x)=\left\lceil x\right\rceil =-\left\lfloor -x\right\rfloor }For example, 23.2 gets rounded to 24, and −23.7 gets rounded to −23.
Rounding toward zero[edit]One may also round toward zero (or truncate, or round away from infinity): y is the integer that is closest to x such that it is between 0 and x (included); i.e. y is the integer part of x, without its fraction digits.
y = truncate ( x ) = sgn ( x ) ⌊ | x | ⌋ = − sgn ( x ) ⌈ − | x | ⌉ = { ⌊ x ⌋ x ≥ 0 ⌈ x ⌉ x