summaryrefslogtreecommitdiff
path: root/lib/mini-gmp.c
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-08-03 07:31:39 -0700
committerKarl Berry <karl@freefriends.org>2021-08-03 07:31:39 -0700
commit8acb4bcef3a829662f196a1d3b4122902ca329d7 (patch)
tree4cca2f31d25be5bda5f6655a9364b408ebfbcef8 /lib/mini-gmp.c
parent6dae7213a2e67c0da56f9bb110e2500df4edeeaa (diff)
downloadgnulib-8acb4bcef3a829662f196a1d3b4122902ca329d7.tar.gz
autoupdate
Diffstat (limited to 'lib/mini-gmp.c')
-rw-r--r--lib/mini-gmp.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/mini-gmp.c b/lib/mini-gmp.c
index 28b159752e..a61ebf312a 100644
--- a/lib/mini-gmp.c
+++ b/lib/mini-gmp.c
@@ -3198,6 +3198,7 @@ void
mpz_rootrem (mpz_t x, mpz_t r, const mpz_t y, unsigned long z)
{
int sgn;
+ mp_bitcnt_t bc;
mpz_t t, u;
sgn = y->_mp_size < 0;
@@ -3216,7 +3217,8 @@ mpz_rootrem (mpz_t x, mpz_t r, const mpz_t y, unsigned long z)
mpz_init (u);
mpz_init (t);
- mpz_setbit (t, mpz_sizeinbase (y, 2) / z + 1);
+ bc = (mpz_sizeinbase (y, 2) - 1) / z + 1;
+ mpz_setbit (t, bc);
if (z == 2) /* simplify sqrt loop: z-1 == 1 */
do {
@@ -3523,7 +3525,8 @@ gmp_stronglucas (const mpz_t x, mpz_t Qk)
mpz_init (V);
/* n-(D/n) = n+1 = d*2^{b0}, with d = (n>>b0) | 1 */
- b0 = mpz_scan0 (n, 0);
+ b0 = mpn_common_scan (~ n->_mp_d[0], 0, n->_mp_d, n->_mp_size, GMP_LIMB_MAX);
+ /* b0 = mpz_scan0 (n, 0); */
/* D= P^2 - 4Q; P = 1; Q = (1-D)/4 */
Q = (D & 2) ? (long) (D >> 2) + 1 : -(long) (D >> 2);
@@ -3555,11 +3558,6 @@ gmp_millerrabin (const mpz_t n, const mpz_t nm1, mpz_t y,
mpz_powm_ui (y, y, 2, n);
if (mpz_cmp (y, nm1) == 0)
return 1;
- /* y == 1 means that the previous y was a non-trivial square root
- of 1 (mod n). y == 0 means that n is a power of the base.
- In either case, n is not prime. */
- if (mpz_cmp_ui (y, 1) <= 0)
- return 0;
}
return 0;
}