summaryrefslogtreecommitdiff
path: root/pow_ui.c
diff options
context:
space:
mode:
authorpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2005-03-30 12:58:45 +0000
committerpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2005-03-30 12:58:45 +0000
commit625669e8ab922c2632e98434aade956e4fd91276 (patch)
tree13cbc3c499dc972ec8012e53df11661bf4d033ca /pow_ui.c
parent60036e019ae639d5705d79924fc425b5fbe22c94 (diff)
downloadmpfr-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.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/pow_ui.c b/pow_ui.c
index 19d3eb9c9..a01d694e3 100644
--- a/pow_ui.c
+++ b/pow_ui.c
@@ -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 */