mpz_export a mpz_t with value 0

Kevin Sopp baraclese at
Fri Jul 3 06:41:06 CEST 2009

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.

I can work around this easily by initializing my destination long long int to 0.

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.

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.

More information about the gmp-bugs mailing list