1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
begin
f1:=1.0;
f2:=0.0;
caught := false;
try
writeln('dividing by zero without having disabled FPU Exceptions...');
writeln(f1/f2);
writeln('no exception was raised');
except on E:Exception do
begin
writeln('Exception occured: ',E.Message);
caught := true;
end;
end;
if not caught then
halt(1);
writeln('Masking exceptions');
writeln(Integer(SetExceptionMask([exDenormalized,exInvalidOp,exOverflow,exPrecision,exUnderflow,exZeroDivide]))); //Returns 61, as expected
writeln(integer(GetExceptionMask)); //Returns 4 - unexpected???
writeln(byte([exZeroDivide])); //Returns 4
caught := false;
try
writeln('dividing by zero with FPU Exceptions disabled...');
writeln(f1/f2);
writeln('no exception was raised');
except on E:Exception do
begin
writeln('Exception occured: ',E.Message);
caught := true;
end;
end;
if caught then
halt(2);
writeln(integer(SetExceptionMask([exDenormalized,exInvalidOp,exOverflow,exPrecision,exUnderflow]))); //Returns 61, as expected
writeln(integer(GetExceptionMask)); //Returns 4 - unexpected???
writeln(byte([exZeroDivide])); //Returns 4
caught := false;
try
writeln('dividing by zero without having disabled FPU Exceptions...');
writeln(f1/f2);
writeln('no exception was raised');
except on E:Exception do
begin
writeln('Exception occured: ',E.Message);
caught := true;
end;
end;
if not caught then
halt(2);
writeln('ok');
end.
|