Newsgroups: rec.arts.int-fiction
Path: nntp.gmd.de!Dortmund.Germany.EU.net!main.Germany.EU.net!EU.net!howland.erols.net!netcom.com!erkyrath
From: erkyrath@netcom.com (Andrew Plotkin)
Subject: Re: [Z-machine] Divison and modulo
Message-ID: <erkyrathDyCqCD.HAr@netcom.com>
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
X-Newsreader: TIN [version 1.2 PL1]
References: <Pine.LNX.3.95.960920173018.5222G-100000@adamant.res.wpi.edu> <erkyrathDy81rB.CsE@netcom.com> <erkyrathDy9vG3.BFG@netcom.com> <52e818$is2@wanda.vf.pond.com> <52e876$j1h@wanda.vf.pond.com>
Date: Thu, 26 Sep 1996 18:07:25 GMT
Lines: 25
Sender: erkyrath@netcom.netcom.com

Matthew T. Russotto (russotto@wanda.vf.pond.com) wrote:
> }}(I should add that if a compiler uses this rule -- that (A % B) always 
> }}has the same sign as A -- it will also follow the rule that (A / B) is 
> }}rounded towards zero, not towards negative infinity.)
> }
> }Just so 
> (A / B) * B + (A % B) = A
> of course.  Darn non-ECC brain cells.

Absolutely nobody has asked, but I uploaded testdiv.inf and testdiv.z5 to 
GMD anyway. It checks your Z-machine to make it follows all these rules.

I'm really impressed, by the way, that this bug went unnoticed for so 
many years. (That ZIP and all derivatives did division wrong.)

I checked through the source code for _So Far_ and found no more than 
four uses of division and modulo -- all of which were of the form 
(random(A) / B) or (random(A) % B), with A and B positive constants. 

--Z

-- 

"And Aholibamah bare Jeush, and Jaalam, and Korah: these were the
borogoves..."
