summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/sub1.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/sub1.c b/src/sub1.c
index 1e9fd72ae..69a2871e1 100644
--- a/src/sub1.c
+++ b/src/sub1.c
@@ -210,7 +210,13 @@ mpfr_sub1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode)
if (MPFR_UNLIKELY (exp_a > __gmpfr_emax))
return mpfr_overflow (a, rnd_mode, MPFR_SIGN (a));
if (MPFR_UNLIKELY (exp_a < __gmpfr_emin))
- goto underflow;
+ {
+ if (rnd_mode == MPFR_RNDN &&
+ (exp_a < __gmpfr_emin - 1 ||
+ (inexact * MPFR_INT_SIGN (a) >= 0 && mpfr_powerof2_raw (a))))
+ rnd_mode = MPFR_RNDZ;
+ return mpfr_underflow (a, rnd_mode, MPFR_SIGN(a));
+ }
MPFR_SET_EXP (a, exp_a);
MPFR_RET (inexact);
}