frexpd32(), frexpd64(), frexpd128() — Extract mantissa and exponent of the decimal floating-point value

Standards

Standards / Extensions C or C++ Dependencies
C/C++ DFP both z/OS® V1.8

Format

#define __STDC_WANT_DEC_FP__
#include <math.h> 

_Decimal32  frexpd32(_Decimal32 x, int *expptr); 
_Decimal64  frexpd64(_Decimal64 x, int *expptr);  
_Decimal128 frexpd128(_Decimal128 x, int *expptr);

_Decimal32  frexp(_Decimal32 x, int *expptr);   /* C++ only */ 
_Decimal64  frexp(_Decimal64 x, int *expptr);   /* C++ only */ 
_Decimal128 frexp(_Decimal128 x, int *expptr);  /* C++ only */

General description

Breaks down the decimal floating-point value x into a component m for the normalized fraction component and another term n for the exponent, such that the absolute value of m is greater than or equal to 0.1 and less than 1.0 or equal to 0, and x = m * 10n. The function stores the integer exponent n at the location to which expptr points.
Notes:
  1. To use IEEE decimal floating-point, the hardware must have the Decimal Floating-Point Facility installed.
  2. These functions work in IEEE decimal floating-point format. See "IEEE Decimal Floating-Point" for more information.

Returned value

Returns the normalized fraction m. If x is 0, the function returns 0 for both the fraction and exponent. The fraction has the same sign as the argument x. The result of the function cannot have a range error.

Example

⁄* CELEBF81

   This example illustrates the frexpd64() function.

*⁄

#define  __STDC_WANT_DEC_FP__
#include <math.h>
#include <stdio.h>

int main(void)
{
   _Decimal64 x, m;
   int n;

   x = 164.5DD;
   m = frexpd64(x, &n);

   printf("The fraction of %Df is %Df and the exponent is %d\n",
          x, m, n);
}

Related information