Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!quintus!ok From: ok@quintus.uucp (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: DIV and MOD ( was: Something IBM did right ) Message-ID: <652@quintus.UUCP> Date: 9 Nov 88 12:00:16 GMT References: <643@quintus.UUCP> <982@goofy.megatest.UUCP> Sender: news@quintus.UUCP Reply-To: ok@quintus.UUCP (Richard A. O'Keefe) Organization: Quintus Computer Systems, Inc. Lines: 32 In article <982@goofy.megatest.UUCP> djones@megatest.UUCP (Dave Jones) writes: >From article <643@quintus.UUCP>, by ok@quintus.uucp (Richard A. O'Keefe): >> Back issues of SigPlan Notices are a good place to look. >Sigplan Notices is one of the most prolific sources of nonsense in >all Computerdom. It doesn't *begin* to compare with comp.lang.c and other newsgroups (:-). There has been a *lot* of good stuff in Sigplan notices. Even some of the bad advice repays careful study to see _why_ it's bad. (I have learned a lot by saying "this is trash" and having someone ask me "why?") >> 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. > >Being an [ex] schoolboy (and an [ex] associate prof of computer sci, who >taught quite a few of the schoolboy's (sic)), I know about the competing definitions. >But this exschoolboy finds all but one of them to be seriously flawed. I thought that when I capitalised "as every schoolboy knows" it could manage without a smiley. It's a well-known catchphrase, after all. BE MORE SPECIFIC. Say *why* you find all the other definitions "seriously flawed". (I can see how a definition can be useless, or awkward, or hard to understand, or difficult to implement in a programming language. But "flawed"?) By the way, whatever sensible definition of remainder one adopts, MOST_NEGATIVE_INTEGER % (-1) ought to be 0 (*anything* % (-1) should be 0). I can imagine implementations (e.g. on an IBM System/370) where the result might be an interrupt, and I know of one machine where the obvious translation would yield rubbish.