Possible bug in mini-gmp (gmp-6.0.0)

bodrato at mail.dm.unipi.it bodrato at mail.dm.unipi.it
Thu May 14 20:51:28 UTC 2015


> Zach Metzinger <zmetzing at pobox.com> writes:
>   the mini-gmp library, I did the following:

>       mpz_set_ui(m, 0);
>       mpz_setbit(m, n-1);

>   While the following code:
>       mpz_set_ui(t0, 1);
>       mpz_mul_2exp(m, t0, n);

Do read the documentation carefully, and consider that, when i>=0 and x is
a correctly initialised mpz,
  mpz_set_ui (x, 0);
  mpz_setbit (x, i);
  mpz_set_ui (x, 1);
  mpz_mul_2exp (x, x, i);
are equivalent.

Sometimes I think we should add an mpz_init_setbit function...


More information about the gmp-bugs mailing list