mpz_export a mpz_t with value 0

Torbjorn Granlund tg at
Fri Jul 3 08:59:10 CEST 2009

Kevin Sopp <baraclese at> writes:

  I use mpz_export to convert mpz_t to long long integers. mpz_export
  uses the early out path if the size of op is zero, which it is for all
  numbers with the value 0. Thus it doesn't store anything in rop.
This is the intended behaviour, and even if there were consensus that
this is not the best behaviour, it is too late to change this.

  However I consider this a bug since there's a discrepancy now with
  mpz_import. I can import a value of 0 but I won't get a value of 0 out
  and that hurts my symmetrical feelings.
Sorry to hurt your feelings...  :-)

  Also, the documentation has a small example for mpz_import which makes
  it appear as if mpz_init doesn't need to be called on the rop.

I made it somewhat clearer.  See the GMP repo.


More information about the gmp-bugs mailing list