Operator: TRUNC
The IEC operator is used for converting the REAL
data type into the DINT
data type. takes only the integer part of the number.
Note
In , the TRUNC
operator converts REAL
into INT
. If you import a V2.3 project, then TRUNC
is automatically replaced by TRUNC_INT
.
If cannot represent the input value by a DINT
or INT
, then the result of this function is undefined. The behavior of such input values is platform-dependent.
Example 178. Example
ST
diVar := TRUNC(1.9); (* Result: 1 *) diVar := TRUNC(-1.4); (* Result: -1 *)