bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

test-strtod: fix typos: s/abs/fabs/


From: Jim Meyering
Subject: test-strtod: fix typos: s/abs/fabs/
Date: Mon, 14 Apr 2008 10:37:22 +0200

Since "abs" truncates any value in (-1..1) to 0, the tests below would
succeed for any value in a much larger than intended range: (-0.5, 1.5).

The corrected (stricter) tests still pass on at least a few targets,
so I've pushed this change:

        test-strtod: fix typos: s/abs/fabs/
        * tests/test-strtod.c (main): Use fabs, not narrowing-to-int "abs".

diff --git a/tests/test-strtod.c b/tests/test-strtod.c
index 6c63e13..12d3606 100644
--- a/tests/test-strtod.c
+++ b/tests/test-strtod.c
@@ -163,7 +163,7 @@ main ()
     /* 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 (abs (result - 0.5) < DBL_EPSILON);
+    ASSERT (fabs (result - 0.5) < DBL_EPSILON);
     ASSERT (ptr == input + 2);
     ASSERT (errno == 0);
   }
@@ -246,7 +246,7 @@ main ()
     /* 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 (abs (result - 0.5) < DBL_EPSILON);
+    ASSERT (fabs (result - 0.5) < DBL_EPSILON);
     ASSERT (ptr == input + 4);
     ASSERT (errno == 0);
   }
--
1.5.5.50.gab781




reply via email to

[Prev in Thread] Current Thread [Next in Thread]