ldexpd32(), ldexpd64(), ldexpd128() — Multiply by a power of ten

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  ldexpd32(_Decimal32 x, int exp); 
_Decimal64  ldexpd64(_Decimal64 x, int exp);
_Decimal128 ldexpd128(_Decimal128 x, int exp);

_Decimal32  ldexp(_Decimal32 x, int exp);   /* C++ only */
_Decimal64  ldexp(_Decimal64 x, int exp);   /* C++ only */
_Decimal128 ldexp(_Decimal128 x, int exp);  /* C++ only */

General description

Calculates the value of x*10exp.
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 calculated value.

Otherwise, if the correct calculated value is outside the range of representable values, ±HUGE_VAL_D32, ±HUGE_VAL_D64, or ±HUGE_VAL_D128 is returned, according to the sign of the value. The value ERANGE is stored in errno to indicate that the result was out of range.

Example

⁄* CELEBL19

   This example illustrates the ldexpd32() function.

   This example computes  y = 1.5*10**5

*⁄

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

int main(void)
{
  _Decimal32 x, y;
  int p;

  x = 1.5DF;
  p = 5;
  y = ldexpd32(x, p);

  printf("%Hf times 10 to the power of %d is %Hf\n", x, p, y);
}

Related information