[E-Lang] Operators #6: Multiplicative operators

Karp, Alan alan_karp@hp.com
Mon, 30 Apr 2001 15:40:27 -0700


Ben Laurie wrote:
> 
> BTW, the maths argument is that you are looking at the interval [0,1)
> which divides equally into [0,.5) and [.5,1), so .5 is 
> actually "nearer"
> to 1 than 0 (by 1/infinity). Hence .5 always rounds up. Rounding down
> would imply the division [0,.5] and (.5,1), which differ by 
> two points.
> 

I am trying to find someone who remembers why rounding is done the way it is
in the IEEE standard.  No luck so far, but one person pointed out that the
choice of round to nearest even has the unfortunate property of causing a
carry when rounding up that does not occur for round to nearest odd.  For
example, when rounding to the position denoted by |, 

	xxx1|1000... 

will cause a carry to propagate when rounding to nearest even, but there
will be no carry for

	xxx0|1000...

when rounding to nearest odd.  Nevertheless,

"Default rounding mode.  An implementation of this standard shall provide
round to nearest, with rounding to even in case of a tie, as the default
rounding mode.  When rounding to nearest, the result shall differ from the
infinite precision exact result by at most one half in the
least-significant-digit position; rounding to even means that if the
difference is exactly half then the rounded result shall have an even last
digit."

IEEE Standard as reported in IEEE Computer 1981

This definition is not the only deviation from pure mathematics in the
standard.  For example, limiting values are not always treated as you might
expect.  Mathematicians thinking that -0 represents 0 approached from below
might be surprised to learn that 0==-0 returns true, and sqrt(-0) is zero.

_________________________
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: Ben Laurie [mailto:ben@algroup.co.uk]
> Sent: Wednesday, April 25, 2001 9:33 AM
> To: Mark S. Miller
> Cc: Bill Frantz; Karp, Alan; E Language Discussions
> Subject: Re: [E-Lang] Operators #6: Multiplicative operators
> 
> 
> "Mark S. Miller" wrote:
> > 
> > At 10:29 AM Monday 4/23/01, Ben Laurie wrote:
> > >"Mark S. Miller" wrote:
> > >> I believe in the IEEE context, "round to nearest" 
> actually means "round to
> > >> even".
> > >
> > >I don't understand what you mean by that - but 1 should 
> round up, of
> > >course (for the same reason 5 does in decimal).
> > 
> > I believe the IEEE "round to even" means: when there's an 
> unambiguous
> > nearest, take that.  When, the true value is exactly half 
> way between the
> > representable values, choose the representable value whose 
> low order bit is
> > 0 rather than 1.  So, using your decimal analogy:
> > 
> >     1.5  rounds to  2
> >     2.5  rounds to  2
> >     3.5  rounds to  4
> > 
> > I take no stance on whether this is a good idea.  It's 
> mandated by IEEE and
> > inherited by Java, so it's what we've got.
> 
> Good Lord! I had no idea!
> 
> BTW, the maths argument is that you are looking at the interval [0,1)
> which divides equally into [0,.5) and [.5,1), so .5 is 
> actually "nearer"
> to 1 than 0 (by 1/infinity). Hence .5 always rounds up. Rounding down
> would imply the division [0,.5] and (.5,1), which differ by 
> two points.
> 
> For those not familiar with the notation, [] include the endpoint, and
> () exclude it.
> 
> I presume the IEEE method gives better accuracy in practice (unless
> using infinite precision :-).
> 
> Cheers,
> 
> Ben.
> 
> --
> http://www.apache-ssl.org/ben.html
> 
> "There is no limit to what a man can do or how far he can go if he
> doesn't mind who gets the credit." - Robert Woodruff
> 
> ApacheCon 2001! http://ApacheCon.com/
> _______________________________________________
> e-lang mailing list
> e-lang@mail.eros-os.org
> http://www.eros-os.org/mailman/listinfo/e-lang
>