* replaced all HandleError() calls to appropriate float_raise() calls

* added overflow handling for fpc_exp_real
* removed arbitrary tabbing by spaces, improving readability somewhat

git-svn-id: trunk@6061 -
This commit is contained in:
tom_at_work 2007-01-18 22:10:32 +00:00
parent 30db0a17db
commit e501fab034

View File

@ -1,8 +1,8 @@
{ {
This file is part of the Free Pascal run time library. This file is part of the Free Pascal run time library.
Copyright (c) 1999-2001 by Several contributors Copyright (c) 1999-2007 by Several contributors
Generic mathemtical routines (on type real) Generic mathematical routines (on type real)
See the file COPYING.FPC, included in this distribution, See the file COPYING.FPC, included in this distribution,
for details about the copyright. for details about the copyright.
@ -610,8 +610,10 @@ invalid:
begin begin
if( d <= 0.0 ) then if( d <= 0.0 ) then
begin begin
if d < 0.0 then if d < 0.0 then begin
d:=0/0; float_raise(float_flag_invalid);
d := 0/0;
end;
result := 0.0; result := 0.0;
end end
else else
@ -697,7 +699,7 @@ invalid:
* = 1 + r + ----------- (for better accuracy) * = 1 + r + ----------- (for better accuracy)
* 2 - R1(r) * 2 - R1(r)
* where * where
* 2 4 10 2 4 10
* R1(r) = r - (P1*r + P2*r + ... + P5*r ). * R1(r) = r - (P1*r + P2*r + ... + P5*r ).
* *
* 3. Scale back to obtain exp(x): * 3. Scale back to obtain exp(x):
@ -768,27 +770,23 @@ invalid:
end end
else else
begin begin
if xsb=0 then if xsb=0 then begin
float_raise(float_flag_overflow);
result:=d result:=d
else end else
result:=0.0; { exp(+-inf)=begininf,0end } result:=0.0; { exp(+-inf)=begininf,0end }
exit; exit;
end; end;
end; end;
if d > o_threshold then if d > o_threshold then begin
begin
float_raise(float_flag_overflow); { overflow } float_raise(float_flag_overflow); { overflow }
result:=huge*huge;
exit; exit;
end; end;
if d < u_threshold then if d < u_threshold then begin
begin
float_raise(float_flag_underflow); { underflow } float_raise(float_flag_underflow); { underflow }
result:=twom1000*twom1000;
exit; exit;
end; end;
end; end;
{ argument reduction } { argument reduction }
if hx > $3fd62e42 then if hx > $3fd62e42 then
begin { if |d| > 0.5 ln2 } begin { if |d| > 0.5 ln2 }
@ -885,11 +883,11 @@ invalid:
px, qx, xx : Real; px, qx, xx : Real;
begin begin
if( d > MAXLOG) then if( d > MAXLOG) then
HandleError(205) float_raise(float_flag_overflow)
else else
if( d < MINLOG ) then if( d < MINLOG ) then
begin begin
HandleError(205); float_raise(float_flag_underflow);
end end
else else
begin begin