This documentation is archived and is not being maintained.


Invokes user-defined trap handler for IEEE floating-point exceptions.

int _fpieee_flt( 
   unsigned long exc_code,
   struct _EXCEPTION_POINTERS *exc_info,
   int handler(_FPIEEE_RECORD *) 


Exception code.
Pointer to the Windows NT exception information structure.
Pointer to user's IEEE trap-handler routine.

Return Value

The return value of _fpieee_flt is the value returned by handler. As such, the IEEE filter routine may be used in the except clause of a structured exception-handling (SEH) mechanism.


The _fpieee_flt function invokes a user-defined trap handler for IEEE floating-point exceptions and provides it with all relevant information. This routine serves as an exception filter in the SEH mechanism, which invokes your own IEEE exception handler when necessary.

The _FPIEEE_RECORD structure, defined in FPIEEE.H, contains information pertaining to an IEEE floating-point exception. This structure is passed to the user-defined trap handler by _fpieee_flt.

_FPIEEE_RECORD field Description
unsigned int RoundingMode,
unsigned int Precision
These fields contain information on the floating-point environment at the time the exception occurred.
unsigned int Operation Indicates the type of operation that caused the trap. If the type is a comparison (_FpCodeCompare), you can supply one of the special _FPIEEE_COMPARE_RESULT values (as defined in FPIEEE.H) in the Result.Value field. The conversion type (_FpCodeConvert) indicates that the trap occurred during a floating-point conversion operation. You can look at the Operand1 and Result types to determine the type of conversion being attempted.
_FPIEEE_VALUE Operand1, _FPIEEE_VALUE Operand2, _FPIEEE_VALUE Operand3, _FPIEEE_VALUE Result These structures indicate the types and values of the proposed result and operands:
OperandValid   Flag indicating whether the responding value is valid.
Format   Data type of the corresponding value. The format type may be returned even if the corresponding value is not valid.
Value   Result or operand data value.

Note: Operand3 is only used with IA64 functions.

_FPIEEE_EXCEPTION_FLAGS Cause, _FPIEEE_EXCEPTION_FLAGS Enable, _FPIEEE_EXCEPTION_FLAGS Status _FPIEEE_EXCEPTION_FLAGS contains one bit-field per type of floating point exception.

There is a correspondence between these fields and the arguments used to mask the exceptions supplied to _controlfp.

The exact meaning of each bit depends on context:

Cause   each set bit indicates the particular exception which was raised.

Enable   each set bit indicates that the particular exception is currently unmasked.

Status   each set bit indicates that the particular exception is currently pending. This includes exceptions that haven't been raised because they were masked out by _controlfp.

Pending exceptions that are disabled will be raised when you enable them. This can result in undefined behavior when using _fpieee_flt as an exception filter. Always call _clearfp before enabling floating point exceptions.


Function Required header Compatibility
_fpieee_flt <fpieee.h> Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.


All versions of the C run-time libraries.


// crt_fpieee.c
/* This program demonstrates the implementation of
 * a user-defined floating-point exception handler using the
 * _fpieee_flt function.

#include <fpieee.h>
#include <excpt.h>
#include <float.h>

int fpieee_handler( _FPIEEE_RECORD * );

int fpieee_handler( _FPIEEE_RECORD *pieee )
   // user-defined ieee trap handler routine:
   // there is one handler for all 
   // IEEE exceptions

   // Assume the user wants all invalid 
   // operations to return 0.

   if ((pieee->Cause.InvalidOperation) && 
       (pieee->Result.Format == _FpFormatFp32)) 
        pieee->Result.Value.Fp32Value = 0.0F;


#define _EXC_MASK    \
    _EM_UNDERFLOW  + \
    _EM_OVERFLOW   + \

int main( void )
   // ...

   __try {
      // unmask invalid operation exception
      _controlfp(_EXC_MASK, _MCW_EM); 

      // code that may generate 
      // fp exceptions goes here
   __except ( _fpieee_flt( GetExceptionCode(),
                fpieee_handler ) ){

      // code that gets control 

      // if fpieee_handler returns


   // ...

See Also

Floating-Point Support Routines | _control87 | Run-Time Routines and .NET Framework Equivalents