Basic instructions
7.7 Conversion operations
S7-1200 Programmable controller
System Manual, 03/2014, A5E02486680-AG
249
ROUND (Round numerical value) and TRUNC (Truncate numerical value)
instructions
Table 7- 83 ROUND and TRUNC instructions
Converts a real number to an integer. For LAD/FBD, you click the "???" in
the instruction box to select the data type for the output, for example "DInt".
For SCL, the default data type for the output of the ROUND instruction is
DINT. To round to another output data type, enter the instruction name with
the explicit name of the data type, for example, ROUND_REAL or
ROUND_LREAL.
The real number fraction is rounded to the nearest integer value (IEEE -
round to nearest). If the number is exactly one-half the span between two
integers (for example, 10.5), then the number is rounded to the even
integer. For example:
• ROUND (10.5) = 10
• ROUND (11.5) = 12
TRUNC converts a real number to an integer. The fractional part of the real
number is truncated to zero (IEEE - round to zero).
1
For LAD and FBD: Click the "???" (by the instruction name) and select a data type from the drop-down menu.
Table 7- 84 Data types for the parameters
SInt, Int, DInt, USInt, UInt, UDInt, Real, LReal
Rounded or truncated output
Table 7- 85 ENO status
1 No error Valid result