Standards / Extensions | C or C++ | Dependencies |
---|---|---|
C/C++ DFP | both | z/OS V1.8 |
#define __STDC_WANT_DEC_FP__
#include <math.h>
_Decimal32 truncd32(_Decimal32 x);
_Decimal64 truncd64(_Decimal64 x);
_Decimal128 truncd128(_Decimal128 x);
_Decimal32 trunc(_Decimal32 x); /* C++ only */
_Decimal64 trunc(_Decimal64 x); /* C++ only */
_Decimal128 trunc(_Decimal128 x); /* C++ only */
The trunc functions round x to the integer value, in decimal floating-point format, nearest to but no larger in magnitude than x.
The trunc functions return the truncated integer value of x.
⁄* CELEBT21
This example illustrates the truncd128() function.
*⁄
#define __STDC_WANT_DEC_FP__
#include <math.h>
#include <stdio.h>
int main(void)
{
_Decimal128 x = 123456789.40DL, y;
y = truncd128(x);
printf("The result of truncd128(%DDf) is %DDf\n", x, y);
}