Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site abnjh.UUCP Path: utzoo!linus!decvax!harpo!eagle!mhuxl!abnjh!usenet From: usenet@abnjh.UUCP (usenet) Newsgroups: net.lang.c Subject: Re: Beware: Hackers - (nf) - integer division Message-ID: <400@abnjh.UUCP> Date: Thu, 12-Jan-84 12:56:45 EST Article-I.D.: abnjh.400 Posted: Thu Jan 12 12:56:45 1984 Date-Received: Fri, 13-Jan-84 06:59:36 EST References: <3459@utzoo.UUCP> Organization: ATTIS, NJ Lines: 17 >> The four most obvious possibilities can be summed >> up in terms of their effects on a non-zero remainder: >> >> 1. Remainder has same sign as dividend. >> 2. Remainder has same sign as divisor. >> 3. Remainder is always positive. >> 4. Magnitude of remainder is minimized, with some decision rule >> for resolving ties (e.g. 5 div 2 == <2, 1> or <3, -1>). >> >> 3 is a bit odd. Not at all, 3 is what most mathematicians would say is *the* correct way to divide two integers. It is most convenient for doing modulo arithmetic. The result of doing n mod m is always less than m and greater or equal to zero. Rick Thomas