summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/fma.c5
-rw-r--r--tests/tfma.c3
2 files changed, 5 insertions, 3 deletions
diff --git a/src/fma.c b/src/fma.c
index 2df3fd3f9..5bc7c28eb 100644
--- a/src/fma.c
+++ b/src/fma.c
@@ -261,9 +261,10 @@ mpfr_fma (mpfr_ptr s, mpfr_srcptr x, mpfr_srcptr y, mpfr_srcptr z,
MPFR_BLOCK_DECL (flags);
if (MPFR_GET_EXP (u) > MPFR_GET_EXP (z) &&
- MPFR_GET_EXP (u) - MPFR_GET_EXP (z) > MPFR_PREC (u) + 1)
+ MPFR_GET_EXP (u) - MPFR_GET_EXP (z) > MPFR_PREC (s) + 1)
{
- /* |z| < ulp(u)/4, therefore one can use z instead of z/4,
+ /* |z| < ulp(u)/4, where the ulp is meant with the precision
+ of the result s, therefore one can use z instead of z/4,
including when u is a power of 2! */
zz = z;
}
diff --git a/tests/tfma.c b/tests/tfma.c
index 07a2f2e65..513308b5b 100644
--- a/tests/tfma.c
+++ b/tests/tfma.c
@@ -216,6 +216,7 @@ test_overflow3 (void)
inex = mpfr_fma (r, x, y, z, MPFR_RNDN);
MPFR_ASSERTN(inex > 0);
MPFR_ASSERTN(mpfr_inf_p (r) && mpfr_sgn (r) > 0);
+ MPFR_ASSERTN(mpfr_overflow_p ());
mpfr_clears (x, y, z, r, (mpfr_ptr) 0);
}
@@ -238,9 +239,9 @@ test_overflow4 (void)
x*y+z = 2^emax - 2^(emax-2p-3) + 2^(emax-3p-3) should overflow,
since it is closest from 2^emax than from 2^emax - 2^(emax-2p-1). */
inex = mpfr_fma (r, x, y, z, MPFR_RNDN);
- mpfr_dump (r);
MPFR_ASSERTN(inex > 0);
MPFR_ASSERTN(mpfr_inf_p (r) && mpfr_sgn (r) > 0);
+ MPFR_ASSERTN(mpfr_overflow_p ());
mpfr_clears (x, y, z, r, (mpfr_ptr) 0);
}