summaryrefslogtreecommitdiff
path: root/pow.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2008-07-21 23:03:36 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2008-07-21 23:03:36 +0000
commit7296518e9057bbe676bc8084d507c08224f3ca55 (patch)
tree4b5a07b5bf3311dbbc8f651b2826eb387ca89729 /pow.c
parent3fbddc4572cc048babddace42cbcb4697b8d11c3 (diff)
downloadmpfr-7296518e9057bbe676bc8084d507c08224f3ca55.tar.gz
pow.c: fixed incorrect rounding in the general case when the result
is negative and rnd = GMP_RNDD or GMP_RNDU (bug20080721 in tpow.c). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@5434 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'pow.c')
-rw-r--r--pow.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/pow.c b/pow.c
index a40c5b1f5..2ff46a9c0 100644
--- a/pow.c
+++ b/pow.c
@@ -459,6 +459,11 @@ mpfr_pow (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, mp_rnd_t rnd_mode)
of x to avoid allocating memory for the significand of absx. */
MPFR_ALIAS(absx, x, /*sign=*/ 1, /*EXP=*/ MPFR_EXP(x));
+ /* We will compute the absolute value of the result. So, let's
+ invert the rounding mode if the result is negative. */
+ if (MPFR_IS_NEG (x) && is_odd (y))
+ rnd_mode = MPFR_INVERT_RND (rnd_mode);
+
/* compute the precision of intermediary variable */
/* the optimal number of bits : see algorithms.tex */
Nt = Nz + 5 + MPFR_INT_CEIL_LOG2 (Nz);