Round (Round Numerical Value) And Trunc (Truncate Numerical Value) Instructions - Siemens S7-1200 System Manual

Hide thumbs Also See for S7-1200:
Table of Contents

Advertisement

7.7.3
ROUND (Round numerical value) and TRUNC (Truncate numerical value)
instructions
Table 7- 83
ROUND and TRUNC instructions
LAD / FBD
SCL
out := ROUND (in);
out := TRUNC(in);
For LAD and FBD: Click the "???" (by the instruction name) and select a data type from the drop-down menu.
1
Table 7- 84
Data types for the parameters
Parameter
Data type
IN
Real, LReal
OUT
SInt, Int, DInt, USInt, UInt, UDInt, Real, LReal
Table 7- 85
ENO status
ENO
Description
1
No error
0
IN is +/- INF or +/- NaN
S7-1200 Programmable controller
System Manual, 03/2014, A5E02486680-AG
Description
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).
7.7 Conversion operations
Description
Floating point input
Rounded or truncated output
Result OUT
Valid result
+/- INF or +/- NaN
Basic instructions
249

Advertisement

Table of Contents
loading

Table of Contents