Trunc_int, Any_..._to conversions, L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual
Page 1074

L-force | PLC Designer
Programming Reference
1072
DMS 4.1 EN 03/2011 TD29
Example in IL:
Examples in ST:
diVar:=TRUNC(1.9); (* Result is 1 *)
diVar:=TRUNC(-1.4); (* Result is -1 *).
TRUNC_INT
IEC Operator: Converting from REAL to INT. The whole number portion of the value
will be used.
Note: TRUNC_INT corresponds to operator TRUNC in »PLC Designer« V2.3 and in
case of a V2.3 import will automatically replace that one. Notice the modified
conversion function of TRUNC in V3.
When you perform a type conversion from a larger to a smaller type, you risk losing
some information.
Example in IL:
Examples in ST:
iVar:=TRUNC_INT(1.9); (* Result is 1 *)
iVar:=TRUNC_INT(-1.4); (* Result is -1 *).
ANY_..._TO Conversions
IEC Operator: Converting from any data type, resp. more specifically from any numeric
data type to another data type. A reasonable choice of data types is assumed.
Syntax:
ANY_NUM_TO_<numeric data type>
ANY_TO_<any data type>
Example:
Conversion from a variable of data type REAL to INT:
re : REAL := 1.234;
i : INT := ANY_TO_INT(re)