Operator ‘TRUNC_INT’¶
This IEC operator is used for converting the REAL
data type into the INT
data type. CODESYS takes only the integer part of the number.
Note
TRUNC_INT
corresponds to the TRUNC
operator in CoDeSys V2.3, and it is used automatically at this point when importing V2.3 projects. Please note the change function of TRUNC
.
If CODESYS cannot represent the input value by a DINT
or INT
, then the result of this function is undefined. The behavior for input values depends on the platform.
Examples
Result in iVAR
: 1
ST:
iVar := TRUNC_INT(1.9); (* Result: 1 *)
iVar := TRUNC_INT(-1.4); (* Result: -1 *)