ROUND: Round numerical value (S7-1200, S7-1500) - STEP 7

FBD (S7-1200, S7-1500)

ft:publication_title
FBD (S7-1200, S7-1500)
Product
STEP 7
Version
V20
Publication date
11/2024
Language
en-US
ROUND: Round numerical value

Description

You can use the "Round numerical value" instruction to round the value at input IN to the nearest integer. The instruction interprets the value at input IN as a floating-point number and converts this to the nearest integer. If the input value is exactly between an even and odd number, then the even number is converted. The result of the instruction is output at the OUT output and can be queried there.

The enable output ENO has the signal state "0" if one of the following conditions applies:

  • Enable input EN has the signal state "0".

  • Errors, such as an overflow, occur during execution.

Parameters

The following table shows the parameters of the "Round numerical value" instruction:

Parameters

Declaration

Data type

Memory area

Description

S7-1200

S7-1500

EN

Input

BOOL

I, Q, M, D, L or constant

I, Q, M, D, L, T, C or constant

Enable input

ENO

Output

BOOL

I, Q, M, D, L

I, Q, M, D, L

Enable output

IN

Input

Floating-point numbers

I, Q, M, D, L, P or constant

I, Q, M, D, L, P or constant

Input value to be rounded.

OUT

Output

Integers, floating-point numbers

I, Q, M, D, L, P

I, Q, M, D, L, P

Result of the rounding

You can select the data types of the instruction from the "???" drop-down lists of the instruction box.

For additional information on valid data types, refer to "See also".

Example

The following example shows how the instruction works:

The following table shows how the instruction works using concrete operand values:

Parameters

Operand

Value

IN

TagIn_Value

1.50000000

-1.50000000

OUT

TagOut_Value

2

-2

If the "TagIn" operand has signal state "1", the instruction is executed. The floating-point number at input "TagIn_Value" is rounded to the nearest even integer and sent to output "TagOut_Value". If the instruction is executed without errors, the "TagOut" output is set.