TRUNC

General Information

For general hints to be considered during type conversion, refer to the chapter Type Conversion Functions.

Definition

IEC operator for conversions from REAL to DINT. The whole number portion of the value will be used.

The result of these functions is not defined if the input value cannot be represented with a DINT or INT. The behavior for such input values is platform-dependent.

Examples in ST

Examples in ST with conversion results:

Example

Result

diVar:=TRUNC(1.9);

1

diVar:=TRUNC(–1.4);

–1

Example in IL

LD                1.9
TRUNC
ST                diVar