diff options
-rw-r--r-- | pow_z.c | 1 | ||||
-rw-r--r-- | tests/tpow.c | 22 |
2 files changed, 23 insertions, 0 deletions
@@ -234,6 +234,7 @@ mpfr_pow_z (mpfr_ptr y, mpfr_srcptr x, mpz_srcptr z, mp_rnd_t rnd) mpfr_clear (t); } + MPFR_SAVE_EXPO_UPDATE_FLAGS (expo, __gmpfr_flags); MPFR_SAVE_EXPO_FREE (expo); return mpfr_check_range (y, inexact, rnd); } diff --git a/tests/tpow.c b/tests/tpow.c index 4f022041b..65acc3b65 100644 --- a/tests/tpow.c +++ b/tests/tpow.c @@ -584,6 +584,7 @@ underflows (void) int err = 0; int inexact; int i; + mp_exp_t emin; mpfr_init2 (x, 64); mpfr_init2 (y, 64); @@ -655,6 +656,27 @@ underflows (void) exit (1); } + emin = mpfr_get_emin (); + mpfr_set_emin (-256); + mpfr_set_prec (x, 2); + mpfr_set_prec (y, 2); + mpfr_set_prec (z, 12); + mpfr_set_ui_2exp (x, 3, -2, GMP_RNDN); + mpfr_set_ui_2exp (y, 1, 38, GMP_RNDN); + mpfr_clear_flags (); + inexact = mpfr_pow (z, x, y, GMP_RNDN); + if (!mpfr_underflow_p () || MPFR_NOTZERO (z) || inexact >= 0) + { + printf ("Bad underflow detection for 0.75^(2^38). Obtained:\n" + "Underflow flag... %-3s (should be 'yes')\n" + "Zero result...... %-3s (should be 'yes')\n" + "Inexact value.... %-3d (should be negative)\n", + mpfr_underflow_p () ? "yes" : "no", + MPFR_IS_ZERO (z) ? "yes" : "no", inexact); + exit (1); + } + mpfr_set_emin (emin); + mpfr_clears (x, y, z, (void *) 0); } |