Path: utzoo!attcan!uunet!ncrlnk!ncr-sd!hp-sdd!hplabs!nsc!voder!apple!desnoyer From: desnoyer@Apple.COM (Peter Desnoyers) Newsgroups: comp.lang.c Subject: Re: /, >>, %, and other ugliness... Message-ID: <20645@apple.Apple.COM> Date: 15 Nov 88 17:13:41 GMT References: <3105@hubcap.UUCP> <34112@XAIT.XEROX.COM> <1700@dataio.Data-IO.COM> <1081@dukeac.UUCP> <1351@mcgill-vision.UUCP> Organization: Apple Computer Inc, Cupertino, CA Lines: 19 In article <1351@mcgill-vision.UUCP> mouse@mcgill-vision.UUCP (der Mouse) writes: >In article <1081@dukeac.UUCP>, sbigham@dukeac.UUCP (Scott Bigham) writes: >> In article <11529@bellcore.bellcore.com> sjs@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