__fp_swapmode() — set IEEE or hexadecimal mode

Standards

Standards / Extensions C or C++ Dependencies
  Both OS/390® V2R6

Syntax

#include <_Ieee754.h>
int __fp_swapmode(int mode);

General description

The __fp_swapmode() function sets a flag to tell C/C++ runtime library functions whether to interpret parameters as IEEE floating-point or hexadecimal floating-point values based on the value of mode as follows:

Value
Description
_FP_MODE_RESET
Use the FLOAT compile option to determine the format of floating-point parameters.
_FP_HFP_MODE
Interpret parameters as hexadecimal floating-point values.
_FP_BFP_MODE
Interpret parameters as IEEE floating-point values.
Usage Notes:
  1. Language Environment Library code and non-Language Environment Library code which have the Language Environment library bit set must use __fp_swapmode() to explicitly set floating point behavior. Failure to do so could result in incorrect floating point values.
  2. Users of the Language Environment library bit which call c-rtl functions which could potentially use floating point values, need to use the __fp_swapmode() function as in the following example.
    1. Customer application compiled for IEEE floating point math, calls the C++ class library.
    2. the C++ class library calls __fp_swapmode(), as follows:
      int custmode;
      
      /*save customer fp mode and set fp mode to HFP */
      custmode = __fp_swapmode (_FP_HFP_MODE);
      
      /* perform call to c-rtl */
      sprintf();
      
      /* restore customer fp mode */
      __fp_setmode(custmode);

Return values

__fp_swapmode() returns a flag (same values as above) with the changed from floating point mode of operation. If __fp_swapmode() is passed a value for fpmode other than the values shown above, the changed-to floating point mode will remain unchanged. The return value will continue to be the changed-from floating point mode.

Related information