You are here: Core Reference > Coding > Logic > SUB

SUB

Function Name

SUB (Subtract)

ST Operator

-

Description

Outputs the result of Input 1 minus Input 2.

Arguments

Input 1 {ANY_MAGNITUDE}

Input 2 {ANY_MAGNITUDE

For more information on the data types for the inputs and outputs, see Data Type Hierarchy.

Returns

Output {Same data type as input}

The Output = Input 1 - Input 2.

Example:

Function Block Diagram - SUB:

The output is the result of the top input minus the bottom input. So, if the top input is 7 and the bottom input is 5, the output is 2 (7-5=2).

ST Program - SUB:

The SUB function is used to provide the result of Input 1 minus Input 2:

  • Output := Input 1 - Input 2;

Where Output, Input 1 and Input 2 are defined as variables earlier in the ST program. In this case, let's assume Input 1 is 17 and Input 2 is 10. The SUB function returns 7 as 17 -10 = 7.

The same effect can be achieved by using the following syntax:

  • Output := SUB (Input 1, Input 2);

ClearSCADA 2015 R2