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 127f9a5..a954c4c 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 182a7bd..04bf7f0 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 717ad7a..3541af4 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 898e6ed..c433089 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 5885457..657948c 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));