ilogbd32(), ilogbd64(), ilogbd128() — Integer unbiased exponent

Standards

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

Format

#define __STDC_WANT_DEC_FP__
#include <math.h>

int  ilogbd32(_Decimal32 x); 
int  ilogbd64(_Decimal64 x);
int  ilogbd128(_Decimal128 x);
int  ilogb(_Decimal32 x);   /* C++ only */
int  ilogb(_Decimal64 x);   /* C++ only */
int  ilogb(_Decimal128 x);  /* C++ only */

General description

Returns the unbiased exponent of its argument x as an integer. For typical numbers, the value returned is the logarithm of |x| rounded down (toward -INF) to the nearest integer value.
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

If successful, these functions return the unbiased exponent of x as an integer.

If x is equal to 0.0, ilogb() will return _FP_DEC_ILOGB0 (= -INT_MAX).

If x is a NaN or infinity, ilogb() will return INT_MAX.

Example

⁄* CELEBI11

   This example illustrates the ilogbd128() function.

*⁄

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

int main(void)
{
   _Decimal128 x = -12345.678901DL;
   int y;

   y = ilogbd128(x);

   printf("The result of ilogbd128(%DDf) is %d\n", x, y);
}

Related information