mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 11:30:31 +02:00
* fix fpc_frac_real to properly thrown an exception on +/-Inf/NaN
This commit is contained in:
parent
03689044d9
commit
201d38d6fe
@ -1757,15 +1757,24 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
{$ifndef FPC_SYSTEM_HAS_FRAC}
|
{$ifndef FPC_SYSTEM_HAS_FRAC}
|
||||||
|
{$push}
|
||||||
|
{ if we have to check manually fpu exceptions, then force the result assignment statement here to
|
||||||
|
throw one }
|
||||||
|
{$CHECKFPUEXCEPTIONS+}
|
||||||
|
{ turn off fastmath as it converts (d-d)/zero into 0 and thus not raising an exception }
|
||||||
|
{$OPTIMIZATION NOFASTMATH}
|
||||||
function fpc_frac_real(d : ValReal) : ValReal;compilerproc;
|
function fpc_frac_real(d : ValReal) : ValReal;compilerproc;
|
||||||
|
const
|
||||||
|
zero: ValReal = 0.0;
|
||||||
begin
|
begin
|
||||||
{ Nan or +/-Inf }
|
{ Nan or +/-Inf }
|
||||||
if (float64high(d) and $7ff00000)=$7ff00000 then
|
if (float64high(d) and $7ff00000)=$7ff00000 then
|
||||||
{ return NaN }
|
{ return NaN }
|
||||||
result := (d-d)/0.0
|
result := zero/zero
|
||||||
else
|
else
|
||||||
result := d - Int(d);
|
result := d - Int(d);
|
||||||
end;
|
end;
|
||||||
|
{$pop}
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user