Lazy mpz allocation

Trevor Spiteri tspiteri at
Fri Apr 20 16:29:55 UTC 2018

>>> Only 0 can have lazy allocation, and I think we document that it isn't
>>> legal to put 0 on the denominator.
>> where is this documented?
> That was in a "I think" sentence. Now that I looked a bit more, I don't 
> find it... Well, you can't call any mpq function that reads that mpq_t, 
> but we don't say you can't write to that mpq_t.

The documentation states that "All rational arithmetic functions assume
operands have a canonical form, and canonicalize their result. The
canonical form means that the denominator and the numerator have no
common factors, and that the denominator is positive."

I always interpreted positive there as greater than zero rather than
non-negative, because calling mpq_canonicalize() will DIVIDE_BY_ZERO if
the denominator is zero.


More information about the gmp-devel mailing list