mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 09:29:26 +02:00
Test fpu exception reset
This commit is contained in:
parent
3cae2ee1a5
commit
023e8976a4
29
tests/test/testfpu2.pp
Normal file
29
tests/test/testfpu2.pp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{$mode objfpc}
|
||||||
|
program test_fpu_excpetions;
|
||||||
|
|
||||||
|
uses
|
||||||
|
sysutils;
|
||||||
|
|
||||||
|
function mysqrt(x : real) : real;
|
||||||
|
|
||||||
|
begin
|
||||||
|
try
|
||||||
|
mysqrt:=sqrt(x);
|
||||||
|
except
|
||||||
|
on e : exception do
|
||||||
|
mysqrt:=0;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
x, y,z : real;
|
||||||
|
|
||||||
|
begin
|
||||||
|
x:=6.5;
|
||||||
|
y:=5.76;
|
||||||
|
z:=3.1;
|
||||||
|
Writeln('Testing mysqrt (x) = sqrt(x) if x >= 0');
|
||||||
|
Writeln(' = 0 if x < 0');
|
||||||
|
Writeln(' 6.5+5.76*mysqrt(3.1) = ',x+y*mysqrt(z):0:6);
|
||||||
|
Writeln(' 6.5+5.76*mysqrt(-3.1) = ',x+y*mysqrt(-z):0:6);
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user