5
$\begingroup$

My textbook says that while rounding a number, if the digit next to the digit to be rounded is a 5, then increment the digit to be rounded by 1 if it is even odd, else do not increase.

I don't understand the logic behind this rule. Why such a discrimination between even and odd?

$\endgroup$
8
  • $\begingroup$ It looks better. $\endgroup$
    – evil999man
    Apr 14, 2014 at 4:09
  • 3
    $\begingroup$ No logic. And there are a zillion rounding rules. The one you quote is by no means the only one for dealing with "round $4.5$ to an integer." But it is the one usually taught in school, so that one can give tests about it and have a clear criterion with which to mark things right or, better, wrong. $\endgroup$ Apr 14, 2014 at 4:11
  • $\begingroup$ @AndréNicolas What is the most widely accepted rule? $\endgroup$ Apr 14, 2014 at 4:14
  • 2
    $\begingroup$ In school, the one you quote. In recording data, if one must round, randomly go up or down. $\endgroup$ Apr 14, 2014 at 4:17
  • 2
    $\begingroup$ There is no reason to close it. It is a perfectly good question, and there may be an at length answer that gives you more information than the Wikipedia article linked to above. $\endgroup$ Apr 14, 2014 at 4:49

1 Answer 1

2
$\begingroup$

The book probably says "if the next digit is a five and either nothing else, or some number of zeroes". For example, 1.5059 should surely be rounded to 1.51, while 1.50500000 would be rounded to 1.50 according to this rule.

If you have an application where you have this situation (the bit to be rounded away is just a five) quite often, then you want a rounding rule where you round up half the time, and round down half the time, so that the average rounding error is 0.

Now lets say you have many numbers with two digits precision. If you calculate the average, you have exactly this situation. Whenever you add two numbers where the last digit is even in one number and odd in the other number, you have to round a digit 5. But as a result, you end up with more numbers where the last digit is even. And if you repeat the procedure and calculate the average of two numbers where the last digit is even, you have a better than normal chance that the last digit will be 0 and there is no rounding error.

That's why this is the rule that is most commonly used by computers for floating-point arithmetic. The average error is zero, and it tends to produce more numbers with the last bit equal to 0, which reduces further rounding errors.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .