program Projekt_08;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  Math,
  Variants,
  Dialogs;

var X, Y, Z, V: Double;
//---------------------------------------------------------
procedure GetFPUPM;
var
  FPUpm: TFPUPrecisionMode;
begin
  SetPrecisionMode(pmDouble);
  FPUpm:=GetPrecisionMode();
  Writeln(VarToStr(FPUpm));
end;
//---------------------------------------------------------
procedure GetFPURM;
var
  FPUrm: TFPURoundingMode;
begin
  FPUrm:=GetRoundMode();
  Writeln(VarToStr(FPUrm)); 
end;
//---------------------------------------------------------
procedure SetSRM;
var
  FPUrm: TFPURoundingMode;
  z: Single;
begin
  SetRoundMode(rmUp);
  //SetRoundMode(rmDown);
  FPUrm:=GetRoundMode();
  Writeln(VarToStr(FPUrm));
  z:=RoundTo(cos(PI/2), -19);
  Writeln(z);
end;
//---------------------------------------------------------
begin
  GetFPUPM;
  GetFPURM;
  SetSRM;
  ClearExceptions(true);
  SetExceptionMask([exInvalidOp, exZeroDivide]);
  if([exInvalidOp, exDenormalized,
     exZeroDivide, exOverflow, exUnderflow,
     exPrecision] * GetExceptionMask) =
     [exInvalidOp, exZeroDivide] then
     Showmessage('Ustalono maski wyjątków:'+
                 ' exInvalidOp, exZeroDivide');

   X:=1.0;
   Y:=0.0;
   Z:=X/Y;      // dzielenie przez 0

   V:=Sqrt(-X); // pierwiastek kwadratowy z liczby ujemnej

   Writeln(V);
   Writeln(Z);
   Readln;
end.

//ClearExceptions()
