[M3devel] LONGINT, looks urgent...

Tony Hosking hosking at cs.purdue.edu
Sun Sep 27 20:59:29 CEST 2009


It works OK for me on I386_DARWIN running with the CVS head.  This  
program produces identical output for both the INTEGER and LONGINT  
values.

Main.m3:

MODULE Main;
IMPORT MainC;

VAR
   a, i: INTEGER;
   aa: LONGINT;
BEGIN
   i := 0;
   FOR ii := 1L TO 1793L DO
     INC(i);
     a := i * 17 DIV 100;
     MainC.PutInt(a);
     aa := ii * 17L DIV 100L;
     MainC.PutLong(aa);
   END;
END Main.

MainC.i3:

INTERFACE MainC;

<*EXTERNAL*> PROCEDURE PutLong (x: LONGINT);
<*EXTERNAL*> PROCEDURE PutInt (x: INTEGER);

END MainC.

MainC.C:

#include <stdio.h>

void PutLong (long long x) {
   printf("%d\n", x);
}

void PutInt (long x) {
   printf("%d\n", x);
}


On 26 Sep 2009, at 15:11, Dragiša Durić wrote:

> Spent a piece of day with
>
> pdv := osnovica * 17L DIV 100L;
>
> varying osnovica from 1, over 1791, 1793... and many more. It looks  
> like
> LONGINT arithmetic in anything except simplest expressions is broken.
> When turned to:
>
> WITH step1 = osnovica * 17L, step2 = step1 DIV 100L DO
>  pdv := step2;
> END;
>
> it works...
>
> I have no much time ATM (doing various M3+Gtk+ tasks right now,  
> tight on
> delivery schedule) to check it more. My version is a bit rusty but not
> much. If nobody makes more research, I'll - few weeks is most  
> earliest I
> can expect any free time.
> -- 
> Dragiša Durić <dragisha at m3w.org>




More information about the M3devel mailing list