Rounding
From Wikipedia, the free encyclopedia
-
For other uses, see Round.
Rounding is the process of reducing the number of significant digits in a number. The result of rounding is a "shorter" number having fewer non-zero digits yet similar in magnitude. The result is less precise but easier to use. There are several slightly different rules for rounding.
Example: 73 rounded to the nearest ten is 70, because 73 is closer to 70 than to 80.
Rounding can be analyzed as a form of quantization.
Contents |
[edit] Common method
This method is commonly used, for example in accounting. It is the one generally taught in basic mathematics classes.
- Decide which is the last digit to keep.
- Increase it by 1 if the next digit is 5 or more (this is called rounding up)
- Leave it the same if the next digit is 4 or less (this is called rounding down)
Example: 3.046 rounded to hundredths is 3.05 (because the next digit [6] is 5 or more).
[edit] Round-to-even method
This method is also known as statistician's rounding or as bankers' rounding. It is identical to the common method of rounding except when the digit(s) following the rounding digit start with a five and have no non-zero digits after it. The new algorithm is:
- Decide which is the last digit to keep.
- Increase it by 1 if the next digit is 6 or more, or a 5 followed by one or more non-zero digits.
- Leave it the same if the next digit is 4 or less
- Round down if the digit you are rounding is even and if the following digit is a five with nothing or zeroes following the five. That is, increase the rounded digit if it is currently odd; leave it if it is already even.
With all rounding schemes there are two possible outcomes: increasing the rounding digit by one or leaving it alone. With traditional rounding, if the number has a value less than the half-way mark between the possible outcomes, it is rounded down; if the number has a value exactly half-way or greater than half-way between the possible outcomes, it is rounded up. The round-to-even method is the same except that numbers exactly half-way between the possible outcomes are sometimes rounded up—sometimes down.
Although it is customary to round the number 4.5 up to 5, in fact 4.5 is no nearer to 5 than it is to 4 (it is 0.5 away from either). When dealing with large sets of scientific or statistical data, where trends are important, traditional rounding on average biases the data upwards slightly. Over a large set of data, or when many subsequent rounding operations are performed as in digital signal processing, the round-to-even rule tends to reduce the total rounding error, with (on average) an equal portion of numbers rounding up as rounding down. This generally reduces the upwards skewing of the result.
Round-to-even is used rather than round-to-odd as the latter rule would prevent rounding to a result of zero.
Examples:
- 3.016 rounded to hundredths is 3.02 (because the next digit (6) is 6 or more)
- 3.013 rounded to hundredths is 3.01 (because the next digit (3) is 4 or less)
- 3.015 rounded to hundredths is 3.02 (because the next digit is 5, and the hundredths digit (1) is odd)
- 3.045 rounded to hundredths is 3.04 (because the next digit is 5, and the hundredths digit (4) is even)
- 3.04501 rounded to hundredths is 3.05 (because the next digit is 5, but it is followed by non-zero digits)
[edit] Other methods of rounding
Other methods of rounding exist, but use is mostly restricted to computers and calculators, statistics and science. In computers and calculators, these methods are used for one of two reasons: speed of computation or usefulness in certain computer algorithms. In statistics and science, the primary use of alternate rounding schemes is to reduce bias, rounding error and drift—these are similar to round-to-even rounding. They make a statistical or scientific calculation more accurate.
[edit] Ease of computation
Other methods of rounding include "round towards zero" (also known as truncation) and "round away from zero". These introduce more round-off error and therefore are rarely used in statistics and science; they are still used in computer algorithms because they are slightly easier and faster to compute. Two specialized methods used in mathematics and computer science are the floor (always round down to the nearest integer) and ceiling (always round up to the nearest integer).
[edit] Statistical accuracy
Stochastic rounding is a method that rounds to the nearest integer, but when the two integers are equidistant (e.g., 3.5), then it is rounded up with probability 0.5 and down with probability 0.5. This reduces any drift, but adds randomness to the process. Thus, if you perform a calculation with stochastic rounding twice, you may not end up with the same answer. The motivation is similar to statistician's rounding.
A classic urban legend recounts that a programmer retired rich after massaging the rounding algorithm in his employer's accounting software and channeling the resulting trickle of cents to his Swiss bank account. Maybe this is not fiction after all, because in Britain many accounting packages do not implement government rules for rounding half-pennies in Value-Added Tax calculations correctly. (Paragraph 17.5 of "The VAT Guide", HM Revenue and Customs Notice 700 says quite clearly: "You may round down the total VAT ... to a whole penny." [dubious — see talk page]) In practice, this means small businesses' invoices are often one penny out from cheques sent in to buy goods by mail order.
[edit] See also
[edit] External links
- Rounding Numbers
- An introduction to different rounding algorithms that is accessible to a general audience but especially useful to those studying computer science and electronics.