[E-Lang] Operators #6: Multiplicative operators
hal@finney.org
hal@finney.org
Mon, 30 Apr 2001 16:28:13 -0700
Alan Karp, <alan_karp@hp.com>, writes:
> I am trying to find someone who remembers why rounding is done the way it is
> in the IEEE standard.
I thought the idea was that rounding in either direction had an equal
effect as far as loss of precision, since it is a tie. And rounding to
even gives you numbers which can be represented accurately in one less
bit of precision, thereby making you lose less precision on subsequent
operations.
Here is an example. Suppose we are rounding to integers, and we will do
a divide by 2 (and round), followed by another divide by 2. Here are
what you get with the three rounding rules for ties of round to even,
round to odd, or round up. I have marked with a * those which are wrong
in the sense that there is a closer integer to the right answer.
N N/4 Even Odd Up
-----------------------------
0 0.00 0 0 0
1 0.25 0 1* 1*
2 0.50 0 1 1
3 0.75 1 1 1
4 1.00 1 1 1
5 1.25 1 1 2*
6 1.50 2 1 2
7 1.75 2 1* 2
8 2.00 2 2 2
(Examples of the derivations: 5/2 = 2.5, round up to 3, 3/2 = 1.5, round
up to 2. Or 7/2 = 3.5, round to odd to 3, 3/2 = 1.5, round to odd to 1.)
Notice that round to even has the fewest errors.
I selected this example at random, so perhaps others will give different
results. But from what I have understood this was the basis for round
to even.
Hal