Round And Truncate Instructions - Siemens SIMATIC S7 System Manual

Hide thumbs Also See for SIMATIC S7:
Table of Contents

Advertisement

100BBasic instructions
7.7 Convert
Table 7- 81
Conversion from Time, DTL, TOD or Date
Data type
Instruction
Time
TIME_TO_DINT
DTL
DTL_TO_DATE, DTL_TO_TOD
TOD
TOD_TO_UDINT
Date
DATE_TO_UINT
Table 7- 82
Conversion from a Char or String
Data type
Instruction
Char
CHAR_TO_SINT, CHAR_TO_USINT,
CHAR_TO_INT, CHAR_TO_UINT,
CHAR_TO_DINT, CHAR_TO_UDINT
CHAR_TO_STRING
String
STRING_TO_SINT, STRING_TO_USINT,
STRING_TO_INT, STRING_TO_UINT,
STRING_TO_DINT, STRING_TO_UDINT,
STRING_TO_REAL, STRING_TO_LREAL
STRING_TO_CHAR
7.7.3

Round and truncate 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
204
Result
The value is transferred to the target data type.
The value is converted.
The value is converted.
The value is converted.
Description
Converts a real number to an integer. 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).
Result
The value is converted.
The value is transferred to the first character of
the string.
The value is converted.
The first character of the string is copied to the
Char.
S7-1200 Programmable controller
System Manual, 11/2011, A5E02486680-05

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Simatic s7-1200

Table of Contents