System.FSetExceptFlag

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function FSetExceptFlag(NewFlags: UInt32; Excepts: UInt32): UInt32;

C++

extern DELPHI_PACKAGE unsigned __fastcall FSetExceptFlag(unsigned NewFlags, unsigned Excepts = (unsigned)(0x3f));

Properties

Type Visibility Source Unit Parent
function public
System.pas
System.hpp
System System

Description

Sets the floating-point exception flags.

FSetExceptFlag sets floating-point exception flags specified by the Excepts parameter to the values indicated by the NewFlags parameter.

Excepts and NewFlags represent combinations of the following values:

Constant
feeINEXACT
feeUNDERFLOW
feeOVERFLOW
feeDIVBYZERO
feeINVALID

FSetExceptFlag returns the previous values of the unit's floating-point exception flags specified in Excepts.

Excepts specifies which exception event flags are to be changed and returned. For example, if Excepts is feeDIVBYZERO and feeINVALID, only these flags are changed according to values in NewFlags and FSetExceptFlag returns the old statuses of only these feeDIVBYZERO and feeINVALID flags.

If Excepts is 0, FSetExceptFlag does not change any flag and returns 0.

By default, Excepts = feeALLEXCEPT. feeALLEXCEPT defines the set of all possible floating-point exception flags.

Example

FSetExceptFlag(0); // Clears all pending floating-point number exceptions.
FSetExceptFlag(0, feeOVERFLOW); // Clears the pending floating-point number's overflow exception flag. Other flags are not changed.
 
FSetExceptFlag(feeALLEXCEPTION, feeOVERFLOW + feeUNDERFLOW); // Sets the overflow and underflow exception flag. Other flags are not changed.
 
FSetExceptFlag(feeOVERFLOW + feeUNDERFLOW); // Sets the overflow and underflow exception flag and clears other in-exact, div-by-zero and invalid-op flags.

Notes:

  • Exception event flag is cumulative. Some platforms support hardware exceptions. If each exception is enabled, the floating-point unit will raise the hardware exception immediately. If the exception is masked, the exception events are kept into the event flag.
  • NewFlags, Excepts and return values are different on each platform. In order to keep compatibility between different platforms, consider using SetExceptions and TArithmeticExceptions.

See Also