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


Ciao,

> 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);
and
  mpz_set_ui (x, 1);
  mpz_mul_2exp (x, x, i);
are equivalent.

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

-- 
http://bodrato.it/papers/



More information about the gmp-bugs mailing list