summaryrefslogtreecommitdiff
path: root/mpz/nextprime.c
diff options
context:
space:
mode:
authorMarco Bodrato <bodrato@mail.dm.unipi.it>2012-06-24 20:01:48 +0200
committerMarco Bodrato <bodrato@mail.dm.unipi.it>2012-06-24 20:01:48 +0200
commite0aedd501ac3527afde22e00bc2a690ea53b0cc8 (patch)
tree40545804dad8ccd0743580f33bcd82bd75c41cd8 /mpz/nextprime.c
parent3ec113088e179c03184171188ef4133dd4786189 (diff)
downloadgmp-e0aedd501ac3527afde22e00bc2a690ea53b0cc8.tar.gz
Use MPN_SIZEINBASE_2EXP to count bits
Diffstat (limited to 'mpz/nextprime.c')
-rw-r--r--mpz/nextprime.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/mpz/nextprime.c b/mpz/nextprime.c
index 9e68ea8a6..c1af45ad0 100644
--- a/mpz/nextprime.c
+++ b/mpz/nextprime.c
@@ -1,6 +1,6 @@
/* mpz_nextprime(p,t) - compute the next prime > t and store that in p.
-Copyright 1999, 2000, 2001, 2008, 2009 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001, 2008, 2009, 2012 Free Software Foundation, Inc.
Contributed to the GNU project by Niels Möller and Torbjorn Granlund.
@@ -43,7 +43,6 @@ mpz_nextprime (mpz_ptr p, mpz_srcptr n)
int i;
unsigned prime_limit;
unsigned long prime;
- int cnt;
mp_size_t pn;
mp_bitcnt_t nbits;
unsigned incr;
@@ -62,8 +61,7 @@ mpz_nextprime (mpz_ptr p, mpz_srcptr n)
return;
pn = SIZ(p);
- count_leading_zeros (cnt, PTR(p)[pn - 1]);
- nbits = pn * GMP_NUMB_BITS - (cnt - GMP_NAIL_BITS);
+ MPN_SIZEINBASE_2EXP(nbits, PTR(p), pn, 1);
if (nbits / 2 >= NUMBER_OF_PRIMES)
prime_limit = NUMBER_OF_PRIMES - 1;
else