Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 1999-12

An overflow problem

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt
to Veselic: I noticed two overflow cases where my fpk (on PC-Linux), performed less satisfactory than…
Veselic wrote 59 lines
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?

I will add it next week.

Michael.

Reply by email

Veselic

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.

Reply by email