Platform SDK: Debugging and Error Handling |
By default, the system has all FP exceptions turned off. Therefore, computations result in NAN or INFINITY, rather than an exception. Before you can trap floating-point (FP) exceptions using structured exception handling, you must call the _controlfp C run-time library function as follows:
// Get the default control word int cw = _controlfp( 0, 0 ); // Set the exception masks off, turn exceptions on cw &=~(EM_OVERFLOW | EM_UNDERFLOW | EM_INEXACT | EM_ZERODIVIDE | EM_DENORMAL // Set the control word _controlfp( cw, MCW_EM );
This turns on all possible FP exceptions To trap only particular exceptions, use only the flags that correspond to the exceptions to be trapped. Note that any handler for FP errors should call _clearfp as its first FP instruction. This function clears floating-point exceptions.