Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!vax135!cornell!uw-beaver!tektronix!hplabs!sri-unix!jrv@mitre-bedford.ARPA From: jrv@mitre-bedford.ARPA Newsgroups: net.lang.c Subject: modulus fn with negatives Message-ID: <13334@sri-arpa.UUCP> Date: Sun, 9-Sep-84 20:29:00 EDT Article-I.D.: sri-arpa.13334 Posted: Sun Sep 9 20:29:00 1984 Date-Received: Fri, 14-Sep-84 06:00:39 EDT Lines: 12 >Should ((-2) % 3) equal -2 or 1? Our machine returns -2, but the posted >corewars game seems to assume a%b always returns 0..b-1; is modulus for >negative lefthand args well defined? What about Pascal mod function? >Modula Modulus? Accepted mathematical definition of modulus? > Merlyn % Leroy K&R apparently allow for either kind, but every time I've USED a modulus function, I needed one that returned a nonnegative number, whether the dividend was positive or negative. Has anyone ever needed the other kind? Has anyone ever needed a modulus with a negative divisor? - Jim Van Zandt