]> sourceware.org Git - glibc.git/commitdiff
Fix strtod test for values above maximum for IBM long double.
authorJoseph Myers <joseph@codesourcery.com>
Thu, 6 Sep 2012 15:33:06 +0000 (15:33 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Thu, 6 Sep 2012 15:33:06 +0000 (15:33 +0000)
ChangeLog
stdlib/gen-tst-strtod-round.c
stdlib/tst-strtod-round.c

index b978444773fc3f32f80995a980512512830c3903..a48a5cb0796029592ef80fc6c519addf32da8e98 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-09-06  Joseph Myers  <joseph@codesourcery.com>
+
+       * stdlib/gen-tst-strtod-round.c: Include <assert.h>.
+       (round_str): Handle values above the maximum for IBM long double
+       as inexact.
+       * stdlib/tst-strtod-round.c (tests): Regenerated.
+
 2012-09-06  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
 
        * sysdeps/s390/s390-32/multiarch/Makefile: Remove -mzarch
index f4ad2701527e677063e9d4922ebdade595800522..56aafab02e5cd63670c108e39f492d19e1cd51eb 100644 (file)
@@ -18,6 +18,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #define _GNU_SOURCE
+#include <assert.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -65,7 +66,19 @@ round_str (const char *s, const char *suffix,
   mpfr_init (f);
   int r = string_to_fp (f, s, MPFR_RNDD);
   if (need_exact)
-    mpfr_printf ("\t%s,\n", r ? "false" : "true");
+    {
+      assert (prec == 106 && emin == -1073 && emax == 1024);
+      /* The maximum value in IBM long double has discontiguous
+        mantissa bits.  */
+      mpfr_t max_value;
+      mpfr_init2 (max_value, 107);
+      mpfr_set_str (max_value, "0x1.fffffffffffff7ffffffffffffcp+1023", 0,
+                   MPFR_RNDN);
+      if (mpfr_cmpabs (f, max_value) > 0)
+       r = 1;
+      mpfr_printf ("\t%s,\n", r ? "false" : "true");
+      mpfr_clear (max_value);
+    }
   print_fp (f, suffix, ",\n");
   string_to_fp (f, s, MPFR_RNDN);
   print_fp (f, suffix, ",\n");
index 1edeff6c17683bf62cc9b9326da1b1158d3ce5b8..c6ad1268733072438578f0322bf60a6d3be371f6 100644 (file)
@@ -1927,7 +1927,7 @@ static const struct test tests[] = {
        0xf.ffffffffffffcp+1020L,
        0xf.ffffffffffffcp+1020L,
        0xf.ffffffffffffcp+1020L,
-       true,
+       false,
        0xf.ffffffffffffcp+1020L,
        0xf.ffffffffffffcp+1020L,
        0xf.ffffffffffffcp+1020L,
@@ -2032,7 +2032,7 @@ static const struct test tests[] = {
        -0xf.ffffffffffffcp+1020L,
        -0xf.ffffffffffffcp+1020L,
        -0xf.ffffffffffffcp+1020L,
-       true,
+       false,
        -0xf.ffffffffffffcp+1020L,
        -0xf.ffffffffffffcp+1020L,
        -0xf.ffffffffffffcp+1020L,
This page took 0.113801 seconds and 5 git commands to generate.