/, >>, %, and other ugliness...

Peter Desnoyers desnoyer at Apple.COM
Wed Nov 16 03:13:41 AEST 1988


In article <1351 at mcgill-vision.UUCP> mouse at mcgill-vision.UUCP (der Mouse) writes:
>In article <1081 at dukeac.UUCP>, sbigham at dukeac.UUCP (Scott Bigham) writes:
>> In article <11529 at bellcore.bellcore.com> sjs at ctt.bellcore.com (Stan Switzer) writes:
>>> Which is to say that you want the MODULUS operation rather than the
>>> REMAINDER operation.
>> Errr... The modulus operation IS the remainder operation.
>
>The range of i MOD n is [0,n); the range of i REM n depends on the
>division operation in use, since REM is the operation such that
>(i REM n) + n * (i DIV n) == i

[forgive me if my algebra is shaky - it's been years...]

Actually, i MOD n maps Z onto Zn, where Zn is the group {integers
modulo n}. The _canonical_ representation of Zn is {0..n-1} - but it
is not the only one. (e.g. {0,1} === {-1,0}) What is braindead is
taking an operation that maps Z -> Z(2n) and calling it MODULO n. 

				Peter Desnoyers



More information about the Comp.lang.c mailing list