truncd32(), truncd64(), truncd128() — Truncate an integer value
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 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 */
General description
The trunc functions round x to the integer value, in decimal floating-point format, nearest to but no larger in magnitude than x.
Notes:
- To use IEEE decimal floating-point, the hardware must have the Decimal Floating-Point Facility installed.
- These functions work in IEEE decimal floating-point format. See "IEEE Decimal Floating-Point" for more information.
Returned value
The trunc functions return the truncated integer value of x.
Example
/* 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);
}