Floating-Point Status Word (ia32 only)

On ia32 systems, the FPU status word includes bits that show the floating-point exception state of the processor. The status word parameters describe six exceptions: invalid result, denormalized result, zero divide, overflow, underflow and inexact precision. These are described in the section, Loss of Precision Errors: Rounding, Special Values, Underflow, and Overflow. When one of the bits is set to 1, it means a past floating-point operation produced that exception type. (Visual Fortran initially clears all status bits. It does not reset the status bits before performing additional floating-point operations after an exception occurs. The status bits accumulate.)

The following table shows the floating-point exception status parameters:

Parameter Name Value in Hex Description
FPSW$MSW_EM #003F Status Mask (set all bits to 1)
FPSW$INVALID #0001 An invalid result occurred
FPSW$DENORMAL #0002 A denormal (very small number) occurred
FPSW$ZERODIVIDE #0004 A divide by zero occurred
FPSW$OVERFLOW #0008 An overflow occurred
FPSW$UNDERFLOW #0010 An underflow occurred
FPSW$INEXACT #0020 Inexact precision occurred

You can find out which exceptions have occurred by retrieving the status word and comparing it to the exception parameters. For example:

 USE DFLIB
 INTEGER(2) status
 CALL GETSTATUSFPQQ(status)
 IF ((status .AND. FPSW$INEXACT) > 0) THEN
    WRITE (*, *) "Inexact precision has occurred"
 ELSE IF ((status .AND. FPSW$DENORMAL) > 0) THEN
    WRITE (*, *) "Denormal occurred"
 END IF

To clear the status word flags, call the CLEARSTATUSFPQQ (ia32 only) routine.