TRUNC_INT

TRUNC_INT 1:

Undefined result if the value range is exceeded

If the input value of a type conversion operator is outside the value range of the output data type, the result of the operation is not defined and depends on the platform. This is the case, for example, when a negative operand value is converted from LREAL to the target data type UINT. An exception error is also possible!

TRUNC_INT 2:

Loss of information possible

If a larger data type is converted to a smaller data type, information may be lost.

The IEC operator is used for conversion from data type REAL to data type INT. TwinCAT only uses the amount of the integer part of the number.

TRUNC_INT 3:

TRUNC_INT corresponds to the operator TRUNC in TwinCAT 2.x PLC and is automatically used instead when importing TwinCAT 2.x PLC projects. Note the changed function of TRUNC.

Examples:

ST code

Result

TRUNC_INT(1.9)

1

TRUNC_INT(-1.4)

-1