GMP Problem with % under C++
Torbjörn Granlund
tg at gmplib.org
Fri Nov 6 11:04:22 UTC 2020
Miki Hermann <hermann at lix.polytechnique.fr> writes:
I am very well familiar with the % operator in %.
Swell.
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++.
Correctamente.
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.
Right, but that is irrelevant since % is not a mathematical modulus
operator. Did you not just say you were "very well familiar" with it?
Did you *really* read the page Marc pointed you to. This is all
mentioned there. Please do read it and get on with your life.
--
Torbjörn
Please encrypt, key id 0xC8601622
More information about the gmp-bugs
mailing list