log2d32(), log2d64(), log2d128() — Calculate the base-2 logarithm

Standards

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

Format

#define __STDC_WANT_DEC_FP__
#include <math.h>

_Decimal32  log2d32(_Decimal32 x); 
_Decimal64  log2d64(_Decimal64 x); 
_Decimal128 log2d128(_Decimal128 x); 

_Decimal32  log2(_Decimal32 x);     /* C++ only */
_Decimal64  log2(_Decimal64 x);     /* C++ only */
_Decimal128 log2(_Decimal128 x);    /* C++ only */

General description

The log2() functions compute the base-2 logarithm of x.

Notes:
  1. These functions work in IEEE decimal floating-point format. See IEEE decimal floating-pointIEEE Decimal Floating-Point for more information.
  2. To use IEEE decimal floating-point, the hardware must have the Decimal Floating-Point Facility installed.

Returned value

The log2 functions return log2 x.

A domain error occurs if x is less than zero.

A range error may occur if x is zero.

Example

⁄* CELEBL28

   This exaxmple illustrates the log2d32() function.

*⁄

#define __STDC_WANT_DEC_FP__
#include <math.h>
#include <stdio.h>
void main(void)
{
   _Decimal32 x, y;

   x = 85.7DF;
   y = log2d32(x);

   printf("log2d32( %Hf ) = %Hf\n", x, y);
}

Related information