mpz_invert returns wrong result

Marc Glisse marc.glisse at inria.fr
Sat Apr 12 22:34:11 UTC 2014


On Sat, 12 Apr 2014, Benjamin Eltzner wrote:

> I potentially found a bug in version 6.0.0 of gmp. Here is the required
> information:
>
> * I run Debian unstable amd64 and use the packaged version 6.0.0 of gmp.
>  (package version number: 2:6.0.0+dfsg-2)
> * A test program is appended.
> * The return value of mpz_invert is wrongly different from 0, when the
>  inverse cannot be calculated (cf. documentation, section 5.9). In the
>  example, the modulus by 1 yields 0, which cannot be inverted. Thus,
>  the result should be 0 but is 1.

https://gmplib.org/gmp6.0.html

First item of the changes in 6.0.0:

   * The function mpz_invert now considers any number invertible in Z/1Z.

(because 0 * x == 1 modulo 1 whatever x)


-- 
Marc Glisse


More information about the gmp-bugs mailing list