On Tue, 29 Jan 2013 17:44:16 EST erik quanstrom <[email protected]> wrote:
> On Tue Jan 29 17:12:15 EST 2013, [email protected] wrote:
> > > i'm not a fp expert, but i think there are two problems here.  first
> > > it is bad form to generate -0 in the emulator, even if it is technically
> > > correct, and second, -0 is defined to be equal to 0 by the spec, so
> > > -0 == 0 should always be true.
> >
> > I think you're right on the second point (I haven't read the IEEE spec
> > lately, just looked at wikipedia), and wrong on the first.  IEEE fp
> > definitely allows for positive and negative zero, so the emulator should
> > be generating them when the spec calls for them to do so.
>
> you might be right about the first point, but i'm really having a hard
> time sorting this out. i don't have the standard, and it's $85.
> this wiki page says there are some rules funny rules for addition/subtraction
> :
> http://en.wikipedia.org/wiki/Signed_zero#Arithmetic
> 
> here's what i have with the as-is fpi
> 
> ; for(i in ocilla ladd kw)cpu -h $i -c /tmp/awktest
> Xeon  -1 + 1 = 0 cmp 0 ok; cmp -0 ok
>       1 + -1 = 0 cmp 0 ok; cmp -0 ok
> Atom  -1 + 1 = 0 cmp 0 ok; cmp -0 ok
>       1 + -1 = 0 cmp 0 ok; cmp -0 ok
> ARM   -1 + 1 = -0 cmp 0 fail; cmp -0 fail
>       1 + -1 = 0 cmp 0 ok; cmp -0 ok
> ; and gcc/amd64 + gawk
>       -1 + 1 = 0 cmp 0 ok; cmp -0 ok

As ieee754 (1985):

  When the sum of two operands with opposite signs (or the
  difference of two operands with like signs) is exactly zero,
  the sign of that sum (or difference) shall be + in all
  rounding modes except round toward -INFINITY, in which mode
  that sign shall be -.

Reply via email to