Newsgroups: rec.arts.int-fiction
Path: nntp.gmd.de!news.ruhr-uni-bochum.de!news.rwth-aachen.de!uni-paderborn.de!golden-gate.owl.de!fu-berlin.de!informatik.tu-muenchen.de!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: <erkyrathDypJpv.798@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> <Pine.LNX.3.95.960927005045.26858C-100000@adamant.res.wpi.edu> <52tt3b$t23@explorer.csc.com> <Pine.LNX.3.95.961002133628.7004E-100000@adamant.res.wpi.edu> <530jla$2m0@explorer.csc.com>
Date: Thu, 3 Oct 1996 16:13:07 GMT
Lines: 45
Sender: erkyrath@netcom.netcom.com

John Ruschmeyer (jruschme@csc.com) wrote:
> [under a CP/M interpreter]
> Hmm... Well, here is the banner from Frotz:
>     FROTZ V1.01 - plays all Infocom games except version 6 (graphic) games.
>     Written by Stefan Jokisch in 1995. This is a standard 0.2 interpreter.
> And the results from it (using the orginal v5 file):
> 	13 * 5 = 65 (ok)
> 	13 * -5 = -65 (ok)
> 	-13 * 5 = -65 (ok)
> 	-13 * -5 = 65 (ok)
> 	13 / 5 = 2 (ok)
> 	13 / -5 = 0 (should be -2!)
> 	-13 / 5 = 13104 (should be -2!)
> 	-13 / -5 = 0 (should be 2!)
> 	13 % 5 = 3 (ok)
> 	13 % -5 = 13 (should be 3!)
> 	-13 % 5 = 3 (should be -3!)
> 	-13 % -5 = -13 (should be -3!)

> I get the same results with the v3 copy. This is on a 486DX2/66 running
> Win95, though I also get the same results on a 386SX16 with 387SX under
> Dos 6.2.

> I'm starting to wonder if it is a Math coprocessor issue as I seem to get
> the same results on the same systems with Zip and WZip.

Those results are the ones typical of doing unsigned 16-bit arithmetic and 
casting the results to signed. (For example, (unsigned)(-13) is 65523, 
divided by 5 is 13104.) This was the bug exhibited by the original ZIP 
code, but the Frotz source does seem to say "(short)a / (short) b". Maybe 
that change was made after version 1.01?

By the way, I checked testdiv.z5 against the Mac Infocom interpreter off 
Beyond Zork. They are consistent. It's also consistent with the PC 
Infocom interpreter, so at *this* point I'm willing to say that 
testdiv.z5 correctly checks for what "the" Z-machine is supposed to do. 
Spec-writers might want to enter this table in the spec -- just saying 
that "division and remainder are signed" isn't enough information.

--Z

-- 

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