The definition of the remainder:
If a and d are integers, with d non-zero, then a remainder is an
integer r such that a = qd + r for some integer q, and with 0 ˜ |r| < |
d|.
This is the correct mathematical definition, as explained in the first
week of any basic maths course, this is why I used the word
"incorrect".
I didn't say it was a bad idea that in C++ (and possibly other
programming languages) they decided to make another definition for the
integer division and the remainder , but I would like to know why.
Thomas, "chip manufacturers aren't certain either which definition to
pick for the modulo operation." Has it anything to do with the
efficiency of the operation or it's that they haven't asked a
mathematician?
Thanks,
OuFeRRaT
On Apr 18, 3:33 am, "Maarten Kronenburg" <M.Kronenb...@[EMAIL PROTECTED]
>
wrote:
> "Seungbeom Kim" wrote in message
> > Maarten Kronenburg wrote:
> > > The remainder has the sign of the dividend,
> > > the modulo has the sign of the divisor
> > > (if not zero).
>
> > Are these commonly accepted definitions?
>
> > Remainder seems to allow both cases, and modulo is actually the name
> > of the operation, not the result.
>
> There is indeed much confusion in literature about this.
> The word remainder however means remainder of the quotient, so that:
> (a / b ) * b + a % b = a
> where / is the quotient symbol and % is the remainder symbol in C++.
> The quotient / is here truncated towards zero (as in C and Fortran).
> The modulo as in a mod b however comes from the mathematical
> residue class ring of x modulo y.
> When / would be truncated towards minus infinity, the modulo would be
the
> remainder.
> In my opinion remainder and modulo are thus two different things, but in
> many literature they are taken to be the same thing.
> In the book "Modern Computer Algebra" (2nd ed) by Von zur Gathen and
> Gerhard, on pages 696 and 697, the remainder and the modulo are also
thus
> separately defined.
> Sometimes the remainder is indicated with a rem b and the modulo with a
mod
> b.
> In C and C++ a rem b is indicated with a % b.
> Following these definitions of remainder and modulo, then the sign of
the a
> rem b (if not zero) is the sign of a, and the sign of a mod b (if not
zero)
> is the sign of b.
> Regards, Maarten.
--
[ See http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


|