summaryrefslogtreecommitdiff
path: root/pow_si.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2003-11-14 12:47:01 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2003-11-14 12:47:01 +0000
commitf3ec3c948ac523a73c8bae0e85592c87bc627a41 (patch)
tree492ba98413f2d85eee5ff193bc6c1ee1f9055632 /pow_si.c
parent4bf22b2dbe424148a8f5e1a61a29b32b6301cd94 (diff)
downloadmpfr-f3ec3c948ac523a73c8bae0e85592c87bc627a41.tar.gz
fixed bug in pow_si (exact result, case z = x)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2548 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'pow_si.c')
-rw-r--r--pow_si.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/pow_si.c b/pow_si.c
index 06073613a..5ce846dbf 100644
--- a/pow_si.c
+++ b/pow_si.c
@@ -71,8 +71,10 @@ mpfr_pow_si (mpfr_ptr y, mpfr_srcptr x, long int n, mp_rnd_t rnd_mode)
/* detect exact powers: x^(-n) is exact iff x is a power of 2 */
if (mpfr_cmp_si_2exp (x, MPFR_SIGN(x), MPFR_EXP(x) - 1) == 0)
{
+ mp_exp_t expx = MPFR_EXP(x); /* warning: x and y may be the same
+ variable */
mpfr_set_si (y, (n % 2) ? MPFR_SIGN(x) : 1, rnd_mode);
- MPFR_EXP(y) += n * (MPFR_EXP(x) - 1);
+ MPFR_EXP(y) += n * (expx - 1);
return 0;
}