Share via


_fpieee_flt

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

int_fpieee_flt(unsignedlongexc_code**,struct_EXCEPTION_POINTERS*exc_info,inthandler(_FPIEEE_RECORD*));**

Function Required Header Compatibility
_fpieee_flt <fpieee.h> Win 95, Win NT

For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version

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.

Parameters

exc_code

Exception code

exc_info

Pointer to the Windows NT exception information structure

handler

Pointer to user’s IEEE trap-handler routine

Remarks

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 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.

Example

/* 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;

        return EXCEPTION_CONTINUE_EXECUTION;
   }
   else
      return EXCEPTION_EXECUTE_HANDLER;
}

#define _EXC_MASK    \
    _EM_UNDERFLOW  + \
    _EM_OVERFLOW   + \
    _EM_ZERODIVIDE + \
    _EM_INEXACT

void main( void )
{
   // ...

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

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

      // code that gets control

      // if fpieee_handler returns
      // EXCEPTION_EXECUTE_HANDLER goes here

   }

   // ...
}

Floating-Point Support Routines

See Also   _control87