diff options
Diffstat (limited to 'stdlib/gen-tst-strtod-round.c')
-rw-r--r-- | stdlib/gen-tst-strtod-round.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/stdlib/gen-tst-strtod-round.c b/stdlib/gen-tst-strtod-round.c index a8f1c60..df9dcaf 100644 --- a/stdlib/gen-tst-strtod-round.c +++ b/stdlib/gen-tst-strtod-round.c @@ -45,6 +45,7 @@ static int string_to_fp (mpfr_t f, const char *s, mpfr_rnd_t rnd) { + mpfr_clear_overflow (); #ifdef WORKAROUND mpfr_t f2; mpfr_init2 (f2, 100000); @@ -73,34 +74,45 @@ static void round_str (FILE *fout, const char *s, int prec, int emin, int emax, bool ibm_ld) { + mpfr_t max_value; mpfr_t f; mpfr_set_default_prec (prec); mpfr_set_emin (emin); mpfr_set_emax (emax); mpfr_init (f); int r = string_to_fp (f, s, MPFR_RNDD); + bool overflow = mpfr_overflow_p () != 0; if (ibm_ld) { 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_clear (max_value); + { + r = 1; + overflow = true; + } } mpfr_fprintf (fout, "\t%s,\n", r ? "false" : "true"); - print_fp (fout, f, ",\n"); + print_fp (fout, f, overflow ? ", true,\n" : ", false,\n"); string_to_fp (f, s, MPFR_RNDN); - print_fp (fout, f, ",\n"); + overflow = (mpfr_overflow_p () != 0 + || (ibm_ld && mpfr_cmpabs (f, max_value) > 0)); + print_fp (fout, f, overflow ? ", true,\n" : ", false,\n"); string_to_fp (f, s, MPFR_RNDZ); - print_fp (fout, f, ",\n"); + overflow = (mpfr_overflow_p () != 0 + || (ibm_ld && mpfr_cmpabs (f, max_value) > 0)); + print_fp (fout, f, overflow ? ", true,\n" : ", false,\n"); string_to_fp (f, s, MPFR_RNDU); - print_fp (fout, f, ""); + overflow = (mpfr_overflow_p () != 0 + || (ibm_ld && mpfr_cmpabs (f, max_value) > 0)); + print_fp (fout, f, overflow ? ", true" : ", false"); mpfr_clear (f); + if (ibm_ld) + mpfr_clear (max_value); } static void |