diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-02-14 23:05:51 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-02-14 23:05:51 +0000 |
commit | 6e5ffc68a8061e42a2680dd99455f89e2f4f8ca9 (patch) | |
tree | 3150eedf9dc6ae8d160042147ff46ac533e723dd /ui_pow_ui.c | |
parent | f095a6c8a44a63379841097ddfbf4682e56e4036 (diff) | |
download | mpfr-6e5ffc68a8061e42a2680dd99455f89e2f4f8ca9.tar.gz |
new coverage tests
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2714 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'ui_pow_ui.c')
-rw-r--r-- | ui_pow_ui.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/ui_pow_ui.c b/ui_pow_ui.c index 26a3131c1..5e1272ead 100644 --- a/ui_pow_ui.c +++ b/ui_pow_ui.c @@ -55,8 +55,8 @@ mpfr_ui_pow_ui (mpfr_ptr x, unsigned long int y, unsigned long int n, mpfr_clear_flags (); inexact = mpfr_set_ui (res, y, GMP_RNDU); err = 1; - /* now 2^(i-1) <= n < 2^i */ - for (i-=2; i>=0; i--) + /* now 2^(i-1) <= n < 2^i: i=1+floor(log2(n)) */ + for (i -= 2; i >= 0; i--) { if (mpfr_mul (res, res, res, GMP_RNDU)) inexact = 1; @@ -65,9 +65,10 @@ mpfr_ui_pow_ui (mpfr_ptr x, unsigned long int y, unsigned long int n, if (mpfr_mul_ui (res, res, y, GMP_RNDU)) inexact = 1; } + /* since the loop is executed floor(log2(n)) times, + we have err = 1+floor(log2(n)). + Since prec >= MPFR_PREC(x) + 4 + floor(log2(n)), prec > err */ err = prec - err; - if (err < 0) - err = 0; } while (inexact && !mpfr_can_round (res, err, GMP_RNDN, GMP_RNDZ, MPFR_PREC(x) + (rnd == GMP_RNDN))); |