diff options
author | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2005-03-30 12:58:45 +0000 |
---|---|---|
committer | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2005-03-30 12:58:45 +0000 |
commit | 625669e8ab922c2632e98434aade956e4fd91276 (patch) | |
tree | 13cbc3c499dc972ec8012e53df11661bf4d033ca /pow_ui.c | |
parent | 60036e019ae639d5705d79924fc425b5fbe22c94 (diff) | |
download | mpfr-625669e8ab922c2632e98434aade956e4fd91276.tar.gz |
Add ceil(log2(size)) bits to initial precision to avoid
commiting in error for huge operands.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@3417 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'pow_ui.c')
-rw-r--r-- | pow_ui.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -21,6 +21,7 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#define MPFR_NEED_LONGLONG_H #include "mpfr-impl.h" /* sets x to y^n, and return 0 if exact, non-zero otherwise */ @@ -88,7 +89,8 @@ mpfr_pow_ui (mpfr_ptr x, mpfr_srcptr y, unsigned long int n, mp_rnd_t rnd) __gmpfr_emin -= 3; /* So that we can check for underflow properly */ /* setup initial precision */ - prec = MPFR_PREC (x) + 3 + BITS_PER_MP_LIMB; + prec = MPFR_PREC (x) + 3 + BITS_PER_MP_LIMB + + MPFR_INT_CEIL_LOG2 (MPFR_PREC (x)); mpfr_init2 (res, prec); rnd1 = MPFR_IS_POS (y) ? GMP_RNDU : GMP_RNDD; /* away */ |