Hello Everyone,

For some reason, I am not able to understand why the following code prints 
different results:

    mpz_t x, n, out;

    mpz_init_set_ui(x, 2UL);
    mpz_init_set_ui(n, 7UL);
    mpz_init(out);

    mpz_invert(out, x, n);
    gmp_printf ("%Zd\n", out);//prints 4. 2 * 4 (mod 7) = 1. OK

    mpz_powm_ui(out, x, -1UL, n);//prints 1. 2 * 1 (mod 7) = 2. How come?
    gmp_printf ("%Zd\n", out);

    mpz_clear(x);
    mpz_clear(n);
    mpz_clear(out);

The documentation states that negative exponents are supported by mpz_powm 
if base^-1 nod n exists. This behavior is the same as in GMP 4.1 on 
Windows. What am I missing here?

Best regards,
Mihai Todor

-- 
You received this message because you are subscribed to the Google Groups 
"mpir-devel" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/mpir-devel/-/Tij5Fx4bv0YJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/mpir-devel?hl=en.

Reply via email to