[lazarus] An overflow problem

Veselic veselic at zagreb.FernUni-Hagen.de
Fri Dec 17 07:02:11 EST 1999


Dear fpk friends,

I noticed two overflow cases where my fpk (on PC-Linux),
performed less satisfactory than expected and in particular
less satisfactory than GNU pascal in the same environment:

Case 1. The program

program test2(input,output);
var 
     b,c:single;
begin {main}
c := 1e+33; 
c := sqr(c);
b := c - c;
writeln(b,' ',c);
end.

was normally compiled and upon execution produced

Run time error  200 at 0x0804F02F
  0xBFFFF894
  0x080480A4
  0x00000000

On the other hand, after compiling the same with GNU pascal,
the execution yielded

 NaN  Inf 

as expected.

Case 2. The program

program test1(input,output);
var 
     c:single;
begin {main}
c := sqr(1e+33);
writeln(c);
end.

the compiler produced the message
Target OS: Linux for i386
Compiling test1.p
Assembling test1
Linking test1
FPE error inside compiler

and the execution yielded a curious output

 4.357678781E-34   

Again, GNU pascal gave

 Inf       

Question: Can one teach freepascal to make equally friendly
outputs in such cases?

Thanks in advance for any help, K. Veselic.






More information about the Lazarus mailing list