diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2008-07-21 23:03:36 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2008-07-21 23:03:36 +0000 |
commit | 7296518e9057bbe676bc8084d507c08224f3ca55 (patch) | |
tree | 4b5a07b5bf3311dbbc8f651b2826eb387ca89729 /pow.c | |
parent | 3fbddc4572cc048babddace42cbcb4697b8d11c3 (diff) | |
download | mpfr-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.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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); |