Trunc

Text Language Definition

Not Applicable

Description

The Trunc Operator block takes a floating point number parameter and returns only the whole number part. Unlike Round, Trunc does not returns the nearest whole number. It returns the number without the decimal part. This truncation is done "towards 0". The truncation of 4.9 is 4. The truncation of -4.9 is -4.

Escapes

The Numerical Operator block does not produce any escapes.

Examples

This compares rounding and truncation:

This returns pi to 2 decimal points. The display still shows 3 decimal points as the default formatting, but the value is truncated.

If "Truncate Down" is needed instead of "Truncate Towards Zero" then this approach could be used:

Related Topics

Round