fp_read_flag() — Return the current floating-point exception status

Standards

Standards / Extensions C or C++ Dependencies
 

both

OS/390 V2R6

Format

#include <float.h>
#include <fpxcp.h>

fpflag_t fp_read_flag()

General description

The fp_read_flag() function returns the current floating-point exception status.

These functions aid in determining both when an exception has occurred and the exception type. These functions can be called explicitly around blocks of code that may cause a floating-point exception.

According to the IEEE Standard for Binary Floating-Point Arithmetic, the following types of floating-point operations must be signaled when detected in a floating-point operation:
  • Non-valid operation
  • Division by zero
  • Overflow
  • Underflow
  • Inexact

A non-valid operation occurs when the result cannot be represented (for example, a square root operation on a number less than 0).

The IEEE Standard for Binary Floating-Point Arithmetic states: “For each type of exception, the implementation shall provide a status flag that shall be set on any occurrence of the corresponding exception when no corresponding trap occurs. It shall be reset only at the user's request. The user shall be able to test and to alter the status flags individually, and should further be able to save and restore all five at one time.”

Floating-point operations can set flags in the floating-point exception status but cannot clear them. Users can clear a flag in the floating-point exception status using an explicit software action such as the fp_clr_flag (0) subroutine.
Note: This function works only in IEEE Binary Floating-Point. See IEEE binary floating-point for more information about IEEE Binary Floating-Point.
The fpxcp.h file defines the following names for the flags indicating floating-point exception status:
FP_INVALID
non-valid operation summary
FP_OVERFLOW
Overflow
FP_UNDERFLOW
Underflow
FP_DIV_BY_ZERO
Division by 0
FP_INEXACT
Inexact result

Returned value

fp_read_flag() returns the current floating-point exception status. The flags in the returned exception status can be tested using the flag definitions above. You can test individual flags or sets of flags.

Related information