EasyManua.ls Logo

Siemens S7-1200 - ROUND (Round Numerical Value) and TRUNC (Truncate Numerical Value) Instructions

Siemens S7-1200
1028 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Basic instructions
7.7 Conversion operations
S7-1200 Programmable controller
System Manual, 03/2014, A5E02486680-AG
249
7.7.3
ROUND (Round numerical value) and TRUNC (Truncate numerical value)
instructions
Table 7- 83 ROUND and TRUNC instructions
LAD / FBD
SCL
Description
out := ROUND (in);
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
out := TRUNC(in);
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
Parameter
Data type
Description
IN
Real, LReal
Floating point input
OUT
SInt, Int, DInt, USInt, UInt, UDInt, Real, LReal
Rounded or truncated output
Table 7- 85 ENO status
ENO
Description
Result OUT
1 No error Valid result
0
IN is +/- INF or +/- NaN
+/- INF or +/- NaN

Table of Contents

Other manuals for Siemens S7-1200

Related product manuals