mpz_mod inside loop
Torbjörn Granlund
tg at gmplib.org
Fri May 17 12:17:25 UTC 2019
I suppressed one line which made my suggested shift-up solution hard to
read. Here is more complete code, with assignment of s:
unsigned long s = mpz_sizeinbase (a, 2);
mpz_mul_2exp (a, a, (GMP_NUMB_BITS - s) % GMP_NUMB_BITS);
Of course, this is equivalent to (-s) % GMP_NUMB_BITS as GMP_NUMB_BITS
divides GMP_NUMB_BITS...
--
Torbjörn
Please encrypt, key id 0xC8601622
More information about the gmp-discuss
mailing list