diff options
author | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2012-06-24 20:01:48 +0200 |
---|---|---|
committer | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2012-06-24 20:01:48 +0200 |
commit | e0aedd501ac3527afde22e00bc2a690ea53b0cc8 (patch) | |
tree | 40545804dad8ccd0743580f33bcd82bd75c41cd8 /mpz | |
parent | 3ec113088e179c03184171188ef4133dd4786189 (diff) | |
download | gmp-e0aedd501ac3527afde22e00bc2a690ea53b0cc8.tar.gz |
Use MPN_SIZEINBASE_2EXP to count bits
Diffstat (limited to 'mpz')
-rw-r--r-- | mpz/get_d_2exp.c | 6 | ||||
-rw-r--r-- | mpz/nextprime.c | 6 |
2 files changed, 4 insertions, 8 deletions
diff --git a/mpz/get_d_2exp.c b/mpz/get_d_2exp.c index c3cf60c9d..b2e2e51ce 100644 --- a/mpz/get_d_2exp.c +++ b/mpz/get_d_2exp.c @@ -1,6 +1,6 @@ /* double mpz_get_d_2exp (signed long int *exp, mpz_t src). -Copyright 2001, 2003, 2004 Free Software Foundation, Inc. +Copyright 2001, 2003, 2004, 2012 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -26,7 +26,6 @@ mpz_get_d_2exp (signed long int *exp2, mpz_srcptr src) { mp_size_t size, abs_size; mp_srcptr ptr; - int cnt; long exp; size = SIZ(src); @@ -38,8 +37,7 @@ mpz_get_d_2exp (signed long int *exp2, mpz_srcptr src) ptr = PTR(src); abs_size = ABS(size); - count_leading_zeros (cnt, ptr[abs_size - 1]); - exp = abs_size * GMP_NUMB_BITS - (cnt - GMP_NAIL_BITS); + MPN_SIZEINBASE_2EXP(exp, ptr, abs_size, 1); *exp2 = exp; return mpn_get_d (ptr, abs_size, size, -exp); } 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 |