diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2008-08-20 12:58:21 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2008-08-20 12:58:21 +0000 |
commit | d2566bdf55821f81dbafd7b9dcf3e3f7544f3aab (patch) | |
tree | 26e20143d9d347182fd21d57797b456fa4405536 /pow.c | |
parent | 5bc110f8d4e1ef4ef87c77a17934f7d78e57f6bf (diff) | |
download | mpfr-d2566bdf55821f81dbafd7b9dcf3e3f7544f3aab.tar.gz |
pow.c: fixed bug in mpfr_pow_general by computing correct bounds
on exp(y*ln|x|). ==> tpow no longer fails in bug20080820.
Note: this bug could affect only underflow cases and possibly cases
near overflow.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@5555 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'pow.c')
-rw-r--r-- | pow.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -197,8 +197,8 @@ mpfr_pow_general (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, /* compute exp(y*ln|x|), using GMP_RNDU to get an upper bound, so that we can detect underflows. */ - mpfr_log (t, absx, GMP_RNDU); /* ln|x| */ - mpfr_mul (t, y, t, GMP_RNDU); /* y*ln|x| */ + mpfr_log (t, absx, MPFR_IS_NEG (y) ? GMP_RNDD : GMP_RNDU); /* ln|x| */ + mpfr_mul (t, y, t, GMP_RNDU); /* y*ln|x| */ if (k_non_zero) { mpfr_const_log2 (u, GMP_RNDD); @@ -235,10 +235,10 @@ mpfr_pow_general (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, if (MPFR_IS_INF (t)) { /* Note: we can probably use a low precision for this test. */ - mpfr_log (t, absx, GMP_RNDD); /* ln|x| */ + mpfr_log (t, absx, MPFR_IS_NEG (y) ? GMP_RNDU : GMP_RNDD); mpfr_mul (t, y, t, GMP_RNDD); /* y * ln|x| */ MPFR_BLOCK (flags2, mpfr_exp (t, t, GMP_RNDD)); - /* t = exp(y * ln|x|) */ + /* t = lower bound on exp(y * ln|x|) */ if (MPFR_OVERFLOW (flags2)) { /* We have computed a lower bound on |x|^y, and it |