mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-10 23:20:29 +02:00
+ check argument range for cosh/sinh
This commit is contained in:
parent
cd13d5bb3a
commit
d4a2f67a6d
@ -1263,12 +1263,19 @@ function arctan2(y,x : float) : float;
|
||||
end;
|
||||
{$endif FPC_MATH_HAS_ARCTAN2}
|
||||
|
||||
const
|
||||
huge: double = 1e300;
|
||||
|
||||
{$ifdef FPC_HAS_TYPE_SINGLE}
|
||||
function cosh(x : Single) : Single;
|
||||
var
|
||||
temp : ValReal;
|
||||
begin
|
||||
if x>8.94159862326326216608E+0001 then
|
||||
begin
|
||||
cosh:=huge+huge;
|
||||
exit;
|
||||
end;
|
||||
temp:=exp(x);
|
||||
{$push}
|
||||
{$safefpuexceptions on}
|
||||
@ -1283,6 +1290,11 @@ function cosh(x : Double) : Double;
|
||||
var
|
||||
temp : ValReal;
|
||||
begin
|
||||
if x>7.10475860073943942030E+0002 then
|
||||
begin
|
||||
cosh:=huge+huge;
|
||||
exit;
|
||||
end;
|
||||
temp:=exp(x);
|
||||
{$push}
|
||||
{$safefpuexceptions on}
|
||||
@ -1307,6 +1319,11 @@ function sinh(x : Single) : Single;
|
||||
var
|
||||
temp : ValReal;
|
||||
begin
|
||||
if x>8.94159862326326216608E+0001 then
|
||||
begin
|
||||
sinh:=huge+huge;
|
||||
exit;
|
||||
end;
|
||||
temp:=exp(x);
|
||||
{ gives better behavior around zero, and in particular ensures that sinh(-0.0)=-0.0 }
|
||||
if temp=1 then
|
||||
@ -1324,6 +1341,11 @@ function sinh(x : Double) : Double;
|
||||
var
|
||||
temp : ValReal;
|
||||
begin
|
||||
if x>7.10475860073943942030E+0002 then
|
||||
begin
|
||||
sinh:=huge+huge;
|
||||
exit;
|
||||
end;
|
||||
temp:=exp(x);
|
||||
if temp=1 then
|
||||
exit(x);
|
||||
|
Loading…
Reference in New Issue
Block a user