Lazy mpz allocation
Vincent Lefevre
vincent at vinc17.net
Fri Apr 20 18:26:05 UTC 2018
On 2018-04-20 18:29:55 +0200, Trevor Spiteri wrote:
> >>> 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.
Yes, but this just means that the user must not call these
functions in such a case. But he can do some work before
calling these functions. In particular, mpq_numref and
mpq_denref should work.
--
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
More information about the gmp-devel
mailing list