diff options
author | zimmerma <zimmerma@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2010-06-18 15:23:16 +0000 |
---|---|---|
committer | zimmerma <zimmerma@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2010-06-18 15:23:16 +0000 |
commit | df9a11589ff309b1dabf75dc951bca6508646cc6 (patch) | |
tree | 9b5aa344d6185728b0b5c08c024996638eb43086 /src | |
parent | 07905d5609ba77717c356622fdc1ad7879a0cba5 (diff) | |
download | mpc-df9a11589ff309b1dabf75dc951bca6508646cc6.tar.gz |
[pow_ui.c] fixed wrong computation of has3 (reported by Yann Laigle-Chapuy)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@793 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'src')
-rw-r--r-- | src/pow_ui.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/pow_ui.c b/src/pow_ui.c index c484500..29fbfe9 100644 --- a/src/pow_ui.c +++ b/src/pow_ui.c @@ -78,9 +78,10 @@ mpc_pow_usi (mpc_ptr z, mpc_srcptr x, unsigned long y, int sign, return mpc_pow_usi_naive (z, x, y, sign, rnd); } - for (l = 0, u = y, has3 = u&3; u > 3; l ++, u >>= 1, has3 |= u&3); - /* l>0 is the number of bits of y, minus 2, thus y has bits: - y_{l+1} y_l y_{l-1} ... y_1 y_0 */ + has3 = y & (y >> 1); + for (l = 0, u = y; u > 3; l ++, u >>= 1); + /* l>0 is the number of bits of y, minus 2, thus y has bits: + y_{l+1} y_l y_{l-1} ... y_1 y_0 */ l0 = l + 2; p = MPC_MAX_PREC(z) + l0 + 32; /* l0 ensures that y*2^{-p} <= 1 below */ mpc_init2 (t, p); |