truncated

truncated(): Integer;

The truncated method of the Decimal primitive type returns an integer containing the truncated value of the receiver.

As the truncated method returns an integer value, an integer overflow situation occurs when the returned integer value is greater than the value of the global constant Max_Integer, which is the limit for the Integer type. To safeguard against this when truncating a large decimal value, use the Decimal type truncatedTo method with a parameter of 0 decimal places. Alternatively use the Decimal type truncated64 method.

The following example shows the use of the truncated method.

testDecimal();
vars
    decimalValue : Decimal [12,4];
begin
    decimalValue := 340.5678;               // Defines the variable value
    decimalValue := (decimalValue / 20).truncated;
    write decimalValue;                     // Outputs 17.0000
end;