More strtod touchups.
authorEric Blake <ebb9@byu.net>
Sun, 30 Mar 2008 21:57:54 +0000 (15:57 -0600)
committerEric Blake <ebb9@byu.net>
Sun, 30 Mar 2008 22:01:25 +0000 (16:01 -0600)
* tests/test-strtod.c (main): Ignore tests for signbit on NaN, and
sign of negative underflow, for now.  Use .5, not .1.
* doc/posix-functions/strtod.texi (strtod): Mention these
limitations.
Reported by Jim Meyering.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
doc/posix-functions/strtod.texi
tests/test-strtod.c

index 5df9267..117ff3d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 
 2008-03-30  Eric Blake  <ebb9@byu.net>
 
+       More strtod touchups.
+       * tests/test-strtod.c (main): Ignore tests for signbit on NaN, and
+       sign of negative underflow, for now.  Use .5, not .1.
+       * doc/posix-functions/strtod.texi (strtod): Mention these
+       limitations.
+       Reported by Jim Meyering.
+
+2008-03-30  Eric Blake  <ebb9@byu.net>
+
        strtod touchups.
        * lib/strtod.c (strtod): Avoid compiler warnings.
        Reported by Jim Meyering.
index fecade3..6e137dd 100644 (file)
@@ -52,7 +52,12 @@ Portability problems not fixed by Gnulib:
 @item
 This function returns a positive value for negative underflow on some
 platforms:
-glibc 2.4, Mingw, Cygwin.
+glibc 2.7, Mingw, Cygwin.
+
+@item
+This function cannot distinguish between ``nan'' and ``-nan'' on some
+platforms:
+glibc 2.7.
 
 @item
 This function fails to correctly parse very long strings on some
index 59fe7e7..996e3da 100644 (file)
@@ -143,10 +143,10 @@ main ()
   }
   {
     errno = 0;
-    const char input[] = ".1";
+    const char input[] = ".5";
     char *ptr;
     double result = strtod (input, &ptr);
-    ASSERT (result == 0.1);
+    ASSERT (result == 0.5);
     ASSERT (ptr == input + 2);
     ASSERT (errno == 0);
   }
@@ -215,10 +215,10 @@ main ()
   }
   {
     errno = 0;
-    const char input[] = "1e-1";
+    const char input[] = "5e-1";
     char *ptr;
     double result = strtod (input, &ptr);
-    ASSERT (result == 0.1);
+    ASSERT (result == 0.5);
     ASSERT (ptr == input + 4);
     ASSERT (errno == 0);
   }
@@ -443,7 +443,7 @@ main ()
   /* Overflow/underflow.  */
   {
     errno = 0;
-    const char input[] = "1E100000";
+    const char input[] = "1E1000000";
     char *ptr;
     double result = strtod (input, &ptr);
     ASSERT (result == HUGE_VAL);
@@ -452,7 +452,7 @@ main ()
   }
   {
     errno = 0;
-    const char input[] = "-1E100000";
+    const char input[] = "-1E1000000";
     char *ptr;
     double result = strtod (input, &ptr);
     ASSERT (result == -HUGE_VAL);
@@ -475,7 +475,13 @@ main ()
     char *ptr;
     double result = strtod (input, &ptr);
     ASSERT (-FLT_MIN <= result && result <= 0.0);
+#if 0
+    /* FIXME - this is glibc bug 5995; POSIX allows returning positive
+       0 on negative underflow, even though quality of implementation
+       demands preserving the sign.  Disable this test until fixed
+       glibc is more prevalent.  */
     ASSERT (signbit (result) == signbit (-0.0));
+#endif
     ASSERT (ptr == input + 10);
     ASSERT (errno == ERANGE);
   }
@@ -539,7 +545,11 @@ main ()
 #ifdef NAN
     ASSERT (isnan (result1));
     ASSERT (isnan (result2));
+# if 0
+    /* Sign bits of NaN is a portability sticking point, not worth
+       worrying about.  */
     ASSERT (signbit (result1) != signbit (result2));
+# endif
     ASSERT (ptr1 == input + 4);
     ASSERT (ptr2 == input + 4);
     ASSERT (errno == 0);
@@ -587,7 +597,11 @@ main ()
 #ifdef NAN
     ASSERT (isnan (result1));
     ASSERT (isnan (result2));
+# if 0
+    /* Sign bits of NaN is a portability sticking point, not worth
+       worrying about.  */
     ASSERT (signbit (result1) != signbit (result2));
+# endif
     ASSERT (ptr1 == input + 6);
     ASSERT (ptr2 == input + 6);
     ASSERT (errno == 0);
@@ -630,7 +644,11 @@ main ()
 #ifdef NAN
     ASSERT (isnan (result1));
     ASSERT (isnan (result2));
+# if 0
+    /* Sign bits of NaN is a portability sticking point, not worth
+       worrying about.  */
     ASSERT (signbit (result1) != signbit (result2));
+# endif
     ASSERT (ptr1 == input + 7);
     ASSERT (ptr2 == input + 7);
     ASSERT (errno == 0);