truncateOnDecimalOverflow

truncateOnDecimalOverflow(bool: Boolean);

The truncateOnDecimalOverflow method of the Process class specifies whether an exception is raised when a decimal overflow occurs.

When you set the bool parameter to true and an exception overflow occurs, the exception that is raised (exception 4043) is continuable.

The following example shows the use of the truncateOnDecimalOverflow method.

vars
    d : Decimal[4,2];
begin
    on Exception do e0(exception);
    process.truncateOnDecimalOverflow(true);
    d := 123.456;
    write d;
    d := -123.456;
    write d;
end;

The following example shows the use of the extendedErrorText property in an exception handler that deals with decimal truncation

e0(e: Exception): Integer;
begin
    // exception 4043 is a 'continuable' decimal overflow
    if e.errorCode = 4043 then
        write e.extendedErrorText;
        // continuing here will result in the value being truncated
        return Ex_Continue;
    endif;
    return Ex_Resume_Next;
end;

This method results in the output of the two write instructions in the first of these examples being 123.456, 23.46, -123.456, and 23.46, respectively.

It is the integral part that is truncated. The fractional part is rounded.

If an exception handler continues this exception, the decimal number is truncated and execution continues; for example, 123.456 is truncated to 23.46 when assigned to a decimal 4,2 (the integral digits are truncated and the fractional digits are rounded). The Exception class extendedErrorText property contains the value of the decimal before it is truncated.