The dectrunc() function
The dectrunc() function truncates a rounded decimal type number to fractional digits.
Syntax
void dectrunc(d, s)
dec_t *d;
mint s;
- d
- A pointer to the decimal structure that contains the rounded number to truncate.
- s
- The number of fractional digits to which to truncate the rounded number. Use a positive integer or zero (0) for this argument.
Usage
The following table shows the sample
output from dectrunc() with various inputs.
Value before truncation | Value of s | Truncated value |
---|---|---|
1.4 | 0 | 1.0 |
1.5 | 0 | 1.0 |
1.684 | 2 | 1.68 |
1.685 | 2 | 1.68 |
1.685 | 1 | 1.6 |
1.685 | 0 | 1.0 |