>From cd825c6d50babc1f4fbaccfee3fff1785fe23cc3 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 1 Feb 2019 02:51:20 +0100 Subject: [PATCH 3/4] strtod, strtold tests: Simplify tests. * tests/test-strtod.c (main): Assume no rounding errors for 0.5. * tests/test-strtold.c (main): Likewise. --- ChangeLog | 6 ++++++ tests/test-strtod.c | 10 ++-------- tests/test-strtold.c | 10 ++-------- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index d4cf812..37c9202 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2019-01-31 Bruno Haible + strtod, strtold tests: Simplify tests. + * tests/test-strtod.c (main): Assume no rounding errors for 0.5. + * tests/test-strtold.c (main): Likewise. + +2019-01-31 Bruno Haible + strtod, strtold: Avoid unnecessary rounding errors. * lib/strtod.c (parse_number): Drop trailing zeroes before doing the decimal to DOUBLE conversion. diff --git a/tests/test-strtod.c b/tests/test-strtod.c index c2297b5..69eb974 100644 --- a/tests/test-strtod.c +++ b/tests/test-strtod.c @@ -155,10 +155,7 @@ main (void) double result; errno = 0; result = strtod (input, &ptr); - /* FIXME - gnulib's version is rather inaccurate. It would be - nice to guarantee an exact result, but for now, we settle for a - 1-ulp error. */ - ASSERT (FABS (result - 0.5) < DBL_EPSILON); + ASSERT (result == 0.5); ASSERT (ptr == input + 2); ASSERT (errno == 0); } @@ -238,10 +235,7 @@ main (void) double result; errno = 0; result = strtod (input, &ptr); - /* FIXME - gnulib's version is rather inaccurate. It would be - nice to guarantee an exact result, but for now, we settle for a - 1-ulp error. */ - ASSERT (FABS (result - 0.5) < DBL_EPSILON); + ASSERT (result == 0.5); ASSERT (ptr == input + 4); ASSERT (errno == 0); } diff --git a/tests/test-strtold.c b/tests/test-strtold.c index cd31787..9815e7a 100644 --- a/tests/test-strtold.c +++ b/tests/test-strtold.c @@ -155,10 +155,7 @@ main (void) long double result; errno = 0; result = strtold (input, &ptr); - /* FIXME - gnulib's version is rather inaccurate. It would be - nice to guarantee an exact result, but for now, we settle for a - 1-ulp error. */ - ASSERT (FABSL (result - 0.5L) < LDBL_EPSILON); + ASSERT (result == 0.5L); ASSERT (ptr == input + 2); ASSERT (errno == 0); } @@ -238,10 +235,7 @@ main (void) long double result; errno = 0; result = strtold (input, &ptr); - /* FIXME - gnulib's version is rather inaccurate. It would be - nice to guarantee an exact result, but for now, we settle for a - 1-ulp error. */ - ASSERT (FABSL (result - 0.5L) < LDBL_EPSILON); + ASSERT (result == 0.5L); ASSERT (ptr == input + 4); ASSERT (errno == 0); } -- 2.7.4