[lazarus] An overflow problem
Michael Van Canneyt
michael.vancanneyt at wisa.be
Fri Dec 17 10:22:24 EST 1999
On Fri, 17 Dec 1999, Veselic wrote:
> 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.
More information about the Lazarus
mailing list