Article View: comp.lang.modula2
Article #4770WriteInt(-32768, n)
From: Robert Barton
Date: Sat, 15 Apr 1989 08:03
Date: Sat, 15 Apr 1989 08:03
29 lines
1301 bytes
1301 bytes
Consider the following simple program:
(* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- *)
MODULE Test;
FROM InOut IMPORT WriteHex, WriteInt, WriteLn;
VAR
int : INTEGER;
BEGIN
int := -32768;
WriteHex(CARDINAL(int), 12);
WriteInt(int, 12); WriteLn
END Test.
(* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- *)
With my system (Modula-2/Amiga by TDI) I get the following output:
8000H -4294934528
I believe I have isolated the problem to WriteInt not taking into account
the fact that -(MIN(INTEGER)) # MAX(INTEGER). I recently came across a
similar assembly example that did the same thing, so I'm wondering how
common this bug is. Could anyone with a different M-2 compiler try this out
and let me know the results.
Technical Details
Message-ID:
<1007@psueea.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!tektronix!psueea!psu-cs.cs.pdx.edu!bartonrShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!tektronix!psueea!psu-cs.cs.pdx.edu!bartonr From: bartonr@psu-cs.cs.pdx.edu (Robert Barton) Newsgroups: comp.lang.modula2 Subject: WriteInt(-32768, n) Message-ID: <1007@psueea.UUCP> Date: 15 Apr 89 08:03:37 GMT Sender: news@psueea.UUCP Reply-To: bartonr@psu-cs.cs.pdx.edu (Robert Barton) Organization: Dept. of Computer Science, Portland State University; Portland OR Lines: 29