Fix bug with -0.0L in previous patch.
authorEric Blake <ebb9@byu.net>
Tue, 11 Dec 2007 21:00:26 +0000 (14:00 -0700)
committerEric Blake <ebb9@byu.net>
Tue, 11 Dec 2007 21:00:26 +0000 (14:00 -0700)
* lib/isnan.c (rpl_isnanl): Make robust to -0.0L and pad bits.
* tests/test-isnan.c (main): Also test on zeroes.
* tests/test-isnanf.c (main): Likewise.
* tests/test-isnanl.h (main): Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
lib/isnan.c
tests/test-isnan.c
tests/test-isnanf.c
tests/test-isnanl.h

index 127f9a5469e25bb9b67bc9c29f978be8379cb346..a954c4cbdec2d6d3751575e618914c5908d71c36 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2007-12-11  Eric Blake  <ebb9@byu.net>
 
+       Fix bug with -0.0L in previous patch.
+       * lib/isnan.c (rpl_isnanl): Make robust to -0.0L and pad bits.
+       * tests/test-isnan.c (main): Also test on zeroes.
+       * tests/test-isnanf.c (main): Likewise.
+       * tests/test-isnanl.h (main): Likewise.
+
        Detect pseudo-denormals on x86 even when cross-compiling.
        * lib/isnan.c (rpl_isnanl) [!KNOWN_EXPBIT0_LOCATION
        && USE_LONG_DOUBLE && x86]: Add one more check to filter out
index 182a7bd5f5f2514f66d97fa6a684958fbf88707e..04bf7f0d9bc023ffacaefec96e2ad7c8dbf76c7d 100644 (file)
@@ -146,8 +146,10 @@ FUNC (DOUBLE x)
       memory_double m1;
       memory_double m2;
 
+      memset (&m1.value, 0, SIZE);
+      memset (&m2.value, 0, SIZE);
       m1.value = x;
-      m2.value = x + 0;
+      m2.value = x + (x ? 0.0L : -0.0L);
       if (memcmp (&m1.value, &m2.value, SIZE) != 0)
         return 1;
 # endif
index 717ad7a9c4229505aa450054b61bd825abf4bec8..3541af4be511e4d314ed7f620f4028f010555de5 100644 (file)
@@ -57,6 +57,8 @@ main ()
   ASSERT (!isnan (-2.718));
   ASSERT (!isnan (-2.718e30));
   ASSERT (!isnan (-2.718e-30));
+  ASSERT (!isnan (0.0));
+  ASSERT (!isnan (-0.0));
   /* Infinite values.  */
   ASSERT (!isnan (1.0 / 0.0));
   ASSERT (!isnan (-1.0 / 0.0));
index 898e6edff9b7526428d7cd1928dd395706fd97cd..c433089900ca1ca5af60470442f86ad5786a8c62 100644 (file)
@@ -57,6 +57,8 @@ main ()
   ASSERT (!isnanf (-2.718f));
   ASSERT (!isnanf (-2.718e30f));
   ASSERT (!isnanf (-2.718e-30f));
+  ASSERT (!isnanf (0.0f));
+  ASSERT (!isnanf (-0.0f));
   /* Infinite values.  */
   ASSERT (!isnanf (1.0f / 0.0f));
   ASSERT (!isnanf (-1.0f / 0.0f));
index 588545705aed5f945bf9af32cf45e651ae601395..657948c94305cfadeeddca9ea5ee2c1ce71bfe22 100644 (file)
@@ -47,6 +47,8 @@ main ()
   ASSERT (!isnanl (-2.718L));
   ASSERT (!isnanl (-2.718e30L));
   ASSERT (!isnanl (-2.718e-30L));
+  ASSERT (!isnanl (0.0L));
+  ASSERT (!isnanl (-0.0L));
   /* Infinite values.  */
   ASSERT (!isnanl (1.0L / 0.0L));
   ASSERT (!isnanl (-1.0L / 0.0L));