Standards / Extensions | C or C++ | Dependencies |
---|---|---|
C/C++ DFP | both | z/OS® V1.8 |
#define __STDC_WANT_DEC_FP__
#include <math.h>
_Decimal32 copysignd32(_Decimal32 x, _Decimal32 y);
_Decimal64 copysignd64(_Decimal64 x, _Decimal64 y);
_Decimal128 copysignd128(_Decimal128 x, _Decimal128 y);
_Decimal32 copysign(_Decimal32 x, _Decimal32 y); /C++ only */
_Decimal64 copysign(_Decimal64 x, _Decimal64 y); /C++ only */
_Decimal128 copysign(_Decimal128 x, _Decimal128 y); /C++ only */
The copysign functions return a value with the magnitude of x and the sign of y.
⁄* CELEBC47
This example illustrates the copysignd64() function.
*⁄
#define __STDC_WANT_DEC_FP__
#include <math.h>
#include <stdio.h>
int main(void)
{
_Decimal64 x = 1.2DD, y = -1.0DD , z;
z = copysignd64(x, y);
printf("The result of copysignd64(%Df,%Df) is %Df\n",x,y,z);
}