Investment Studio > Expressions > Functions > Math & Trig > TRUNC

float trunc(float number, integer digits = 0)

Returns the number, truncated to the specified number of digits.

If digits >= 0, number is truncated to digits decimal places.

If digits < 0, number is truncated digits places left of the decimal point.

If left out, digits defaults to 0.

While trunc(number) and int(number) are similar, they return different results when the number is negative: trunc(-4.5) = -4 (fractional part removed), while int(-4.5) = -5 (rounded down to nearest integer).

Examples

=trunc(3.5)

equals 3

=trunc(-6.5)

equals -6.

See also ceiling, even, floor, frac, int, mround, odd, round, rounddown, roundup.