trunc(X;Y)
Returns the result of rounding the first given value to the multiple of the second given value, always rounding in the direction of 0. (Available as of version 16.02)
Syntax
trunc(X;Y)
Input
Argument | Type | Description |
---|---|---|
X |
any numeric type | The number to round to the multiple of Y |
Y |
any numeric type | The multiple to round X |
Return Value
Returns a numeric value corresponding to X
, rounded to the multiple of
Y
, but always rounding in the direction of
0 (down if X
is positive and up if
X
is negative).
If both X
and Y
are integers, the result is an integer;
otherwise, the result is a decimal number.
If X
and/or Y
is N/A, the result is N/A.
trunc(X;Y)
is similar to round(X;Y)
,
but trunc(X;Y)
always rounds in the direction of 0.
For example, trunc(1234.567;0.1)
returns a value of
1234.5
, while
round(1234.567;0.1)
returns a value of
1234.6
Sample Usage
X |
Y |
trunc(X;Y) |
---|---|---|
149.456 | 0.01 | 149.45 (decimal) |
149.456 | 1 | 149 (decimal) |
-149.456 | 0.05 | -149.45 (decimal) |
-149.456 | 5 | -145 (decimal) |
7 | 5 | 5 (integer) |
-8 | 5 | -5 (integer) |
8.0 | 5 | 5(decimal) |
NA | 1 | NA (integer) |
1.0 | NA | NA (decimal) |
NA | NA | NA (integer) |