The documentation makes no sense. The prototype says it is an unsigned long, which can never be negative.
We should amend the documentation. It would make sense if there were an mpz_powm_si function. Bill. On 24 June 2012 22:21, michael85 <todormi...@gmail.com> wrote: > There's a small copy / paste gone wrong issue in the code: mpz_powm_ui(out, > x, -1UL, n). Unfortunately, even after I remove the UL, the behavior is the > same. > > Mihai > > > On Sunday, June 24, 2012 10:47:36 PM UTC+2, michael85 wrote: >> >> 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/-/1VgKlOh8w4kJ. > > To post to this group, send email to mpir-devel@googlegroups.com. > To unsubscribe from this group, send email to > mpir-devel+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/mpir-devel?hl=en. -- You received this message because you are subscribed to the Google Groups "mpir-devel" group. To post to this group, send email to mpir-devel@googlegroups.com. To unsubscribe from this group, send email to mpir-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/mpir-devel?hl=en.