mpz_invert returns wrong result

Niels Möller nisse at
Sun Apr 13 08:17:38 UTC 2014

Benjamin Eltzner <b.eltzner at> writes:

> "If the inverse exists, the return value is non-zero and rop will
> satisfy 0 < rop < abs(op2)."

That should b 0 <= rop < abs(op2) then, to cover also the zero-ring

> In the example code I sent, rop = 0 but if I understand your reasoning
> correctly, it should be 1.

If we think it makes sense to talk about inverses at all in the zero
ring (which we do, hence this change in gmp-6.0.0), then I think it
makes the most sense to return the canonical representation of the
inverse, which is 0.


Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.

More information about the gmp-bugs mailing list