mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 07:09:23 +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;
|
end;
|
||||||
{$endif FPC_MATH_HAS_ARCTAN2}
|
{$endif FPC_MATH_HAS_ARCTAN2}
|
||||||
|
|
||||||
|
const
|
||||||
|
huge: double = 1e300;
|
||||||
|
|
||||||
{$ifdef FPC_HAS_TYPE_SINGLE}
|
{$ifdef FPC_HAS_TYPE_SINGLE}
|
||||||
function cosh(x : Single) : Single;
|
function cosh(x : Single) : Single;
|
||||||
var
|
var
|
||||||
temp : ValReal;
|
temp : ValReal;
|
||||||
begin
|
begin
|
||||||
|
if x>8.94159862326326216608E+0001 then
|
||||||
|
begin
|
||||||
|
cosh:=huge+huge;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
temp:=exp(x);
|
temp:=exp(x);
|
||||||
{$push}
|
{$push}
|
||||||
{$safefpuexceptions on}
|
{$safefpuexceptions on}
|
||||||
@ -1283,6 +1290,11 @@ function cosh(x : Double) : Double;
|
|||||||
var
|
var
|
||||||
temp : ValReal;
|
temp : ValReal;
|
||||||
begin
|
begin
|
||||||
|
if x>7.10475860073943942030E+0002 then
|
||||||
|
begin
|
||||||
|
cosh:=huge+huge;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
temp:=exp(x);
|
temp:=exp(x);
|
||||||
{$push}
|
{$push}
|
||||||
{$safefpuexceptions on}
|
{$safefpuexceptions on}
|
||||||
@ -1307,6 +1319,11 @@ function sinh(x : Single) : Single;
|
|||||||
var
|
var
|
||||||
temp : ValReal;
|
temp : ValReal;
|
||||||
begin
|
begin
|
||||||
|
if x>8.94159862326326216608E+0001 then
|
||||||
|
begin
|
||||||
|
sinh:=huge+huge;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
temp:=exp(x);
|
temp:=exp(x);
|
||||||
{ gives better behavior around zero, and in particular ensures that sinh(-0.0)=-0.0 }
|
{ gives better behavior around zero, and in particular ensures that sinh(-0.0)=-0.0 }
|
||||||
if temp=1 then
|
if temp=1 then
|
||||||
@ -1324,6 +1341,11 @@ function sinh(x : Double) : Double;
|
|||||||
var
|
var
|
||||||
temp : ValReal;
|
temp : ValReal;
|
||||||
begin
|
begin
|
||||||
|
if x>7.10475860073943942030E+0002 then
|
||||||
|
begin
|
||||||
|
sinh:=huge+huge;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
temp:=exp(x);
|
temp:=exp(x);
|
||||||
if temp=1 then
|
if temp=1 then
|
||||||
exit(x);
|
exit(x);
|
||||||
|
Loading…
Reference in New Issue
Block a user