Run-Time Subroutine: Returns the floating-point processor status word. This routine is only available on ia32 processors.
Module: USE DFLIB
Syntax
The floating-point status word shows whether various floating-point exception conditions have occurred. Visual Fortran initially clears (sets to 0) all status flags, but after an exception occurs it does not reset the flags before performing additional floating-point operations. A status flag with a value of one thus shows there has been at least one occurence of the corresponding exception. The following table lists the status flags and their values:
Parameter name | Hex value | Description |
---|---|---|
FPSW$MSW_EM | #003F | Status Mask (set all flags 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 use a logical comparison on the status word returned by GETSTATUSFPQQ to determine which of the six floating-point exceptions listed in the table has occurred.
An exception is disabled if its flag is set to 1 and enabled if its flag is cleared to 0. By default, the denormal, underflow and inexact precision exceptions are disabled, and the invalid, overflow and divide-by-zero exceptions are enabled. Exceptions can be enabled and disabled by clearing and setting the flags with SETCONTROLFPQQ. You can use GETCONTROLFPQQ to determine which exceptions are currently enabled and disabled.
If an exception is disabled, it does not cause an interrupt when it occurs. Instead, floating-point processes generate an appropriate special value (NaN or signed infinity), but the program continues. You can find out which exceptions (if any) occurred by calling GETSTATUSFPQQ.
If errors on floating-point exceptions are enabled (by clearing the flags to 0 with SETCONTROLFPQQ), the operating system generates an interrupt when the exception occurs. By default, these interrupts cause run-time errors, but you can capture the interrupts with SIGNALQQ and branch to your own error-handling routines.
For a full discussion of the floating-point status word, exceptions, and error handling, see The Floating-Point Environment in the Programmer's Guide.
Compatibility
CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS DLL LIB
See Also: SETCONTROLFPQQ, GETCONTROLFPQQ, SIGNALQQ, MATHERRQQ, CLEARSTATUSFPQQ
Example
! Program to demonstrate GETSTATUSFPQQ
USE DFLIB
INTEGER(2) status
CALL GETSTATUSFPQQ(status)
! check for divide by zero
IF (IAND(status, FPSW$ZERODIVIDE) .NE. 0) THEN
WRITE (*,*) 'Divide by zero occurred. Look &
for NaN or signed infinity in resultant data.'
END IF
END