Hello, I changed your program somewhat:
PROGRAM espa; var i, j, k : integer; esp, res : double;
begin writeln (exp(1.0)); for i := 1 to 50000 do begin esp := i * 0.1 ; res := exp ( -esp ); writeln (' Minus the exponential of ', esp :5 :1, ' is ', res ); end end.
Last lines written are: ...... Minus the exponential of 744.9 is 4.940656458412465e-324 Minus the exponential of 745.0 is 4.940656458412465e-324 Minus the exponential of 745.1 is 4.940656458412465e-324 espa: error in exponentiation (Numerical result out of range) (error #700 at 8049c8a)
This indicates that res runs into undefined range between zero and minimum valid value of IEEE double precision numbers. Minimum decimal value is approximately +/- 10**(-323). If your application allows lower values to be interpreted as zero (0.0) you may tell it to gpc, but I don't know how to do that..
Ernst-Ludwig
On Tue, 26 Mar 2002, Silvio a Beccara wrote:
Hello,
I tried compiling this simple program, with GPC RC3 (20020304), with GCC 2.95.3 (20010315).
program espa;
var
i, j, k: integer;
esp: double;
res: double;
begin
for i := 1 to 50 do begin
esp := i * 1000 ;
res := exp ( -esp );
writeln (' Minus the exponential of ', esp :1 :0, ' is ', res :1 :15 );
end;
end.
Surprisingly, and disappointingly, when I run it I get the following result:
espa: error in exponentiation (Numerical result out of range) (error #700 at 8049c75)
while with any Pascal (like FPC), and C compiler, I get no error (like it should be ). It really looks like a bug.
Can anyone help?
Thanks, regards
Silvio a Beccara