278 Rockwell Automation Publication 1756-RM003N-EN-P - October 2011
Chapter 6 Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS)
Structured Text
divide_result := float_value_1 / float_value_2;
Function Block
Example 2: The DIV and MOV instructions work together to divide two integers, round the
result, and place the result in an integer tag:
• The DIV instruction divides dint_a by dint_b.
• To round the result, the Destination is a REAL tag. (If the destination was
an integer tag (SINT, INT, or DINT), the instruction would truncate the
result.)
• The MOV instruction moves the rounded result (real_temp) from the
DIV to divide_result_rounded.
• Since divide_result_rounded is a DINT tag the value from real_temp is
rounded and placed in the DINT destination.
Relay Ladder