summaryrefslogtreecommitdiff
path: root/fma.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2002-01-18 15:40:30 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2002-01-18 15:40:30 +0000
commitdc65c4294a14faf05855b69da5a11cd434ba8f3c (patch)
tree0625b70775c7bf5121122aca3e690f8449bbe1ee /fma.c
parent650976ea9dfe0ea39c5a230a8c78772d36cffab9 (diff)
downloadmpfr-dc65c4294a14faf05855b69da5a11cd434ba8f3c.tar.gz
Cases 0 * 0 + 0.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@1660 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'fma.c')
-rw-r--r--fma.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/fma.c b/fma.c
index 5db5989e2..45310087e 100644
--- a/fma.c
+++ b/fma.c
@@ -88,7 +88,25 @@ mpfr_fma (mpfr_ptr s, mpfr_srcptr x, mpfr_srcptr y, mpfr_srcptr z,
MPFR_CLEAR_INF(s);
if (MPFR_IS_ZERO(x) || MPFR_IS_ZERO(y))
- return mpfr_set (s, z, rnd_mode);
+ {
+ if (MPFR_IS_ZERO(z))
+ {
+ int sign_p, sign_z;
+ sign_p = MPFR_SIGN(x) * MPFR_SIGN(y);
+ sign_z = MPFR_SIGN(z);
+ if (MPFR_SIGN(s) !=
+ (rnd_mode != GMP_RNDD ?
+ ((sign_p < 0 && sign_z < 0) ? -1 : 1) :
+ ((sign_p > 0 && sign_z > 0) ? 1 : -1)))
+ {
+ MPFR_CHANGE_SIGN(s);
+ }
+ MPFR_SET_ZERO(s);
+ MPFR_RET(0);
+ }
+ else
+ return mpfr_set (s, z, rnd_mode);
+ }
if (MPFR_IS_ZERO(z))
return mpfr_mul (s, x, y, rnd_mode);