DIV and MOD ( was: Something IBM did right )

Richard A. O'Keefe ok at quintus.uucp
Wed Nov 9 22:00:16 AEST 1988


In article <982 at goofy.megatest.UUCP> djones at megatest.UUCP (Dave Jones) writes:
>From article <643 at quintus.UUCP>, by ok at 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.



More information about the Comp.lang.c mailing list