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.
}
{
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);
}
}
{
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);
}
/* Overflow/underflow. */
{
errno = 0;
- const char input[] = "1E100000";
+ const char input[] = "1E1000000";
char *ptr;
double result = strtod (input, &ptr);
ASSERT (result == HUGE_VAL);
}
{
errno = 0;
- const char input[] = "-1E100000";
+ const char input[] = "-1E1000000";
char *ptr;
double result = strtod (input, &ptr);
ASSERT (result == -HUGE_VAL);
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);
}
#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);
#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);
#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);