Path: utzoo!utgpu!attcan!uunet!husc6!bloom-beacon!bu-cs!mirror!necntc!necis!mrst!sdti!turner From: turner@sdti.UUCP (Prescott K. Turner) Newsgroups: comp.lang.c Subject: Re: DIV and MOD ( was: Something IBM did right ) Summary: sensible DIV and MOD Message-ID: <328@sdti.UUCP> Date: 9 Nov 88 17:36:18 GMT References: <972@goofy.megatest.UUCP> <643@quintus.UUCP> Reply-To: turner@sdti.UUCP (0006-Prescott K. Turner, Jr.) Organization: Software Development Technologies, Sudbury MA Lines: 21 In article <643@quintus.UUCP> ok@quintus.UUCP (Richard A. O'Keefe) writes: >As Every Schoolboy Knows, there are at least three sensible definitions of >integer division/remainder, all of which agree which divisor and dividend >are positive. To call all three definitions "sensible" is inviting a war. To me the arguments Dave Jones presented make sense and the counterarguments do not. Actually, I do accept as a counterargument that most programming languages require the definition in which the quotient is truncated towards 0. But it's a shame that they went down that path. >Note that the Pascal standard does not define integer division and >remainder for non-positive divisors. The Pascal standard defines integer division for all divisors except 0. Standard Pascal's "mod" operator does not give the remainder from "div", even for positive divisors. The committee decided that while "div" had to be like all of the other languages, "mod" should be sensible. -- Prescott K. Turner, Jr. Software Development Technologies, Inc. 375 Dutton Rd., Sudbury, MA 01776 USA (508) 443-5779 UUCP:...genrad!mrst!sdti!turner