DIV and MOD ( was: Something IBM did right )

Stan Switzer sjs at jcricket.ctt.bellcore.com
Wed Nov 9 00:48:15 AEST 1988


In article <972 at goofy.megatest.UUCP> djones at megatest.UUCP (Dave Jones) writes:
> As is Mr. Switzer, I too am absolutely certain that I know
> how / and % should be defined for negative dividends.  Peculiar 
> that we should not agree! :-)  We agree on the MOD issue, but
> not on DIV.  Or maybe not.  First he says that IBM "did it right":
>    > Please, do not argue that integer -1/2 should be -1...
> But that is, or course, truncation toward a smaller value.
> (-1 is smaller than -0.5)
> Perhaps he will want to clarify.

OOPS!  I goofed.  I meant 0 not -1.

I agree completely with your followup.

One day while I was hacking Postscript it occurred to me to see if
Adobe was clever enough to do it right.  After all, grapgics is one of
the areas where it really matters how / and % work.  I am sad to say
that Postscript does it wrong too.  And here it is impossible to
blame the hardware, as the cost of making it work right would be
insignificant compared to the interpreter overhead.

Stan Switzer   sjs at ctt.bellcore.com



More information about the Comp.lang.c mailing list