TRUNC: Truncate 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
TRUNC: Truncate numerical value

Description

You can use the "Truncate numerical value" instruction to form an integer from the value at input IN. The value at input IN is interpreted as a floating-point number. The instruction selects only the integer part of the floating-point number and sends this to output OUT without decimal places.

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 instruction "Truncate numerical value":

Parameters

Declaration

Data type

Memory area

Description

EN

Input

BOOL

I, Q, M, D, L or constant

Enable input

ENO

Output

BOOL

I, Q, M, D, L

Enable output

IN

Input

Floating-point numbers

I, Q, M, D, L or constant

Input value as floating-point number

OUT

Output

Integers, floating-point numbers

I, Q, M, D, L

Result with integer part of the floating-point number

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

1

-1

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