[E-Lang] Operators #6: Multiplicative operators

Karp, Alan alan_karp@hp.com
Tue, 1 May 2001 09:55:49 -0700


Hal Finney wrote:
> 
> 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
> 

However, multiplication and division by powers of 2 only affect the exponent
field of the floating point number unless we're in the denorm range.

_________________________
Alan Karp
Principal Scientist
Decision Technology Department
Hewlett-Packard Laboratories MS 1U-3
1501 Page Mill Road
Palo Alto, CA 94304
(650) 857-3967, fax (650) 857-6278
https://ecardfile.com/id/Alan_Karp
http://www.hpl.hp.com/personal/Alan_Karp/
 

> -----Original Message-----
> From: hal@finney.org [mailto:hal@finney.org]
> Sent: Monday, April 30, 2001 4:28 PM
> To: e-lang@eros-os.org
> Subject: RE: [E-Lang] Operators #6: Multiplicative operators
> 
> 
> 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
> _______________________________________________
> e-lang mailing list
> e-lang@mail.eros-os.org
> http://www.eros-os.org/mailman/listinfo/e-lang
>