Return x truncated to the specified number of decimal places.
Declared in <bdldfp_decimalutil.h>
static
Decimal32
trunc(
Decimal32 x,
unsigned int precision);
Return the specified x value truncated to the specified precision decimal places. Round towards zero, regardless of the current decimal floating point rounding mode. If precision of x is less than or equal the precision or x is positive zero, negative zero, NaN, or infinity then return x itself.
Examples: trunc(3.14159, 3) ==> 3.141
x truncated to the specified number of decimal places
| Name | Description |
|---|---|
| x | value to truncate |
| precision | number of decimal places to retain |