gm2
[Top][All Lists]
Advanced

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

[Gm2] Some LONGINT questions, problems


From: John B. Wallace, Jr.
Subject: [Gm2] Some LONGINT questions, problems
Date: Wed, 29 Dec 2004 21:14:58 -0500

First:

The MAX function does not appear to work properly on LONGINT. LONGCARD  is
OK.(CVS sources dated 2004/12/22).


MODULE MaxLongIntBug;

FROM StrIO IMPORT WriteLn;

FROM NumberIO IMPORT WriteCard;

FROM FpuIO IMPORT WriteLongInt;

VAR
   i : LONGINT;
   k : LONGCARD;

BEGIN
   (* MAX function does not work properly for LONGINT *)
   i := MAX(LONGINT);
   WriteLongInt(i,0);
   WriteLn;
   (* MAX function does not work properly for LONGINT *)
   WriteLongInt(MAX(LONGINT),0);
   WriteLn;
   (* MAX function appears to work properly for LONGCARD *)
   k := MAX(LONGCARD);
   (* I could not find a WriteLongCard procedure in the gm2 libraries? *)
   WriteLongInt(k/2,0);
   WriteLn;
   WriteCard(MAX(CARDINAL),0);
   WriteLn;
   (* MAX function appears to work properly for LONGCARD *)
   k := MAX(LONGCARD)/MAX(CARDINAL);;
   WriteLongInt(k,0);
   WriteLn
END MaxLongIntBug.


On my system the code above produces this output:

2147483647
2147483647
9223372036854775807
4294967295
4294967297


Second:

Should the following code work or should it generate an error?
(passing a INTEGER to a LONGINT parameter or a CARDINAL to a LONGCARD)

MODULE TestLongParam;

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

FROM StrIO IMPORT WriteLn;

FROM FpuIO IMPORT WriteLongInt;

VAR
  Int  : INTEGER;
  Card : CARDINAL;

PROCEDURE LongIntParameter ( LongInt : LONGINT );
  BEGIN
    WriteLongInt(LongInt,0);
    WriteLn
  END LongIntParameter;

PROCEDURE LongCardParameter ( LongCard : LONGCARD );
  BEGIN
    (* I could not find a WriteLongCard procedure in the gm2 libraries? *)
    WriteLongInt(LongCard,0);
    WriteLn
  END LongCardParameter;

BEGIN
  Int := 1234;
  LongIntParameter(Int);
  WriteLn;
  Card := 12345678;
  LongCardParameter(Card);
  WriteLn
END TestLongParam.


On my system the code above compiles without error and produces the
following
output:


433791698130

433804042574



Finally, at this point I haven't not found any problems with LONGINT or
LONGCARD
assignment or constants in the 2004/12/22 release.


John Wallace




reply via email to

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