Each bit mask corresponds to a unique floating-point exception that can be masked individually. The following bit mask values are defined in <float.h>.
| Bit Mask | Description |
|---|---|
| EM_INVALID | Mask exceptions resulting from
floating-point operations that are not valid. Such an
exception can be caused by a floating-point value that is
not valid, such as a signaling NaN, or by a problem with
the floating-point unit stack. The corrective action taken by the 80387 chip is to return a quiet NaN. This type of exception indicates a serious problem and you should not mask it off. |
| EM_DENORMAL | Mask exceptions resulting from the use
of floating-point values that have not been normalised.
The corrective action is to use these values and allow
for gradual underflow. This type of exception is ignored by IBM C and C++ Compilers and is masked off by default. |
| EM_ZERODIVIDE | Mask the divide-by-zero exception. A value of infinity is returned. |
| EM_OVERFLOW | Mask the overflow exception. A value of infinity is returned. |
| EM_UNDERFLOW | Mask the underflow exception. Either a denormalised number or zero is returned. |
| EM_INEXACT | Mask the exception that indicates
precision has been lost. Because this type of exception is only useful when performing integer arithmetic, while the 80387 chip is used for floating-point arithmetic only, the exception is not meaningful and the 80387 chip ignores it. This exception is masked off by default. |
All floating-point exceptions are masked by default.
The first of the following statements masks the floating-point underflow exception from being reported, and the second statement masks it on again.
oldstate = _control87(EM_UNDERFLOW, EM_UNDERFLOW);
oldstate = _control87(0, EM_UNDERFLOW);
![]()
Exception Handling for
Floating-Point Exceptions