GMP Problem with % under C++

Miki Hermann hermann at lix.polytechnique.fr
Fri Nov 6 09:22:05 UTC 2020


I am very well familiar with the % operator in %. In the document,
whose link you sent me, and which I have read before, it is mentioned
that

Function: mpz_class operator% (mpz_class a, mpz_class d)

This means, that the % operator in GMP overloads the usual % operator
in C++.

Just to recall you, for integer a and b, b > 0, the result of the
modulus operator is an integer in the range 0..b-1. If a is negative,
the result is equal to (k*b + a) % b for any positive integer k making
the expression (k*b + a) positive. By definition for a >= 0 and b > 0,
we have a = q*b + (a % b), where q is an integer called quotient.

Best regards,
Miki

On Thu, 2020-11-05 at 22:15 +0100, Marc Glisse wrote:
> On Thu, 5 Nov 2020, Miki Hermann wrote:
> 
> > I am not sure if I used the GMP package properly or if I did
> > everything
> > right, but it seems to me that very probably there is a problem
> > somewhere in the GMP package and/or its interface with C++.
> 
> It is very probable that you are not familiar with the % operator in
> C or 
> C++, and that you did not read our documentation at
> 
> https://gmplib.org/manual/C_002b_002b-Interface-Integers
> 



More information about the gmp-bugs mailing list