Name

Set8087CW Procedure

Syntax

procedure Set8087CW(ControlWord: Word);

Description

The Set8087CW procedure sets the floating-point control word and saves the value of the ControlWord variable in Default8087CW. Set8087CW is a real procedure.

Tips and Tricks

  • See the Intel architecture manuals to learn more about the floating-point control word.

  • Common uses for Set8087CW are to change the floating-point precision, exception mask, and rounding mode. Make sure you do not reduce the floating-point precision if you are using the Comp or Currency types.

Example

type
  TRoundMode = (rmNearest, rmDown, rmUp, rmZero);
  TPrecisionMode = (pmSingle, pmReserved, pmDouble, pmExtended);
  TExceptionMask = (emInvalid, emDenormalized, emZeroDivide,
                    emOverflow, emUnderflow, emPrecision);
  TExceptionMasks = set of TExceptionMask;

  TFpuControl = record
    RoundMode: TRoundMode;
    Precision: TPrecisionMode;
    ExceptionMask: TExceptionMasks;
  end;
const
  RoundShift = 10;
  PrecisionShift = 8;

// Set the floating-point control word in a structured manner.
procedure SetFpuCW(const FpuCW: TFpuControl);
var
  CW: Word;
begin
  CW := Byte(FpuCW.ExceptionMask);
  CW := CW or (Ord(FpuCW.Precision) shl PrecisionShift);
  CW := CW or (Ord(FpuCW.RoundMode) shl RoundShift);
  Set8087CW(CW);
end;

See Also

Comp Type, Currency Type, Default8087CW Variable, Extended Type, Int Function, Round Function, Trunc Function
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset