gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gm2] StringConvert dialect


From: John B Wallace Jr
Subject: [Gm2] StringConvert dialect
Date: Wed, 28 Sep 2005 21:09:45 -0400
User-agent: KMail/1.8

There seems to be a slight problem with the StringConvert module. It appears
that it is written in the PIM2/PIM3 dialect and when compiled with the default
dialect of the most recent gm2 (PIM4 I believe), it produces some errors.


The two test modules below produce an incorrect result for MIN(INTEGER) and
MIN(LONGINT) when built with the 16Sep05 version of gm2:


MODULE InOutBug;

(*******************************************************************)
(*        NOTE: THIS IS TEST CODE AND MAY BE INCORRECT             *)
(*******************************************************************)

FROM InOut IMPORT WriteInt, WriteLn;

BEGIN
  WriteInt(MAX(INTEGER),0);
  WriteLn;
  WriteInt(MIN(INTEGER),0);
  WriteLn;
  WriteInt(MIN(INTEGER)+1,0);
  WriteLn
END InOutBug.

The output is:

2147483647
-2147483658
-2147483647


MODULE FpuIOBug;

(*******************************************************************)
(*        NOTE: THIS IS TEST CODE AND MAY BE INCORRECT             *)
(*******************************************************************)

FROM StrIO IMPORT WriteLn;

FROM FpuIO IMPORT WriteLongInt;

BEGIN
  WriteLongInt(MAX(LONGINT),0);
  WriteLn;
  WriteLongInt(MIN(LONGINT),0);
  WriteLn;
  WriteLongInt(MIN(LONGINT)+1,0);
  WriteLn
END FpuIOBug.

The output is:

+9223372036854775807
-9223372036854775818
-9223372036854775807


I was able to correct the problem by compiling the StringConvert
module with the -Wpim2/-Wpim3 switch or by changing the StringConvert
code very slightly, replacing a few DIV with / and a few MOD with REM
in the first part of the IntegerToString and LongIntegerToString procedures.

The NumberIO module may have the same problem.

John Wallace












reply via email to

[Prev in Thread] Current Thread [Next in Thread]