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 theComp
orCurrency
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 |
Get Delphi in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.