Standards / Extensions | C or C++ | Dependencies |
---|---|---|
C/C++ DFP | both | z/OS® V1.8 |
#define __STDC_WANT_DEC_FP__
#include <math.h>
_Decimal32 powd32(_Decimal32 x, _Decimal32 y);
_Decimal64 powd64(_Decimal64 x, _Decimal64 y);
_Decimal128 powd128(_Decimal128 x, _Decimal128 y);
_Decimal32 pow(_Decimal32 x, _Decimal32 y); /* C++ only */
_Decimal64 pow(_Decimal64 x, _Decimal64 y); /* C++ only */
_Decimal128 pow(_Decimal128 x, _Decimal128 y); /* C++ only */
If successful, the powd32(), powd64(), and powd128() functions return the value of x to the power of y.
If x is negative or 0, then the y parameter must be an integer. If y is 0, the function returns 1.0 for all x parameters.
If an overflow occurs, the function returns HUGE_VAL_D32, HUGE_VAL_D64, or HUGE_VAL_D128 and sets errno to ERANGE.
If x is negative and y is not an integer, the function returns NaNQ and sets errno to EDOM.
If x is 0 and y is negative, the function returns HUGE_VAL_D32, HUGE_VAL_D64, or HUGE_VAL_D128 but does not modify errno.
⁄* CELEBP59
This example illustrates the powd64() function
*⁄
#define __STDC_WANT_DEC_FP__
#include <math.h>
#include <stdio.h>
int main(void)
{
_Decimal64 x, y, z;
x = 2.0DD;
y = 3.0DD;
z = powd64(x, y);
printf("%Df to the power of %Df is %Df\n", x, y, z);
}