**Definition**

The Compare instruction is a ladder logic rung input instruction that evaluates an arithmetic expression. If the expression is true the logic to the right of the instruction, or rung-condition-out, is enabled and disabled if the expression is false. The Compare instruction is slower and uses more memory than other comparison instructions; however it allows complex expressions in one instruction.

The expression is defined using tags, math operators, and constants. Parentheses ( ) are used to give priority to sections of an expression. Here is a full list of arithmetic operands.

Expressions are executed in a predetermined order of operation, not the order they are written in. To change the order place sections of the expression in parentheses as an expression enclosed in parentheses will execute first.

**Order Operation**

- 1 () Parentheses
- 2 ABS, ACS, ASN, ATN, COS, DEG, FRD, LN, LOG, RAD, SIN, SQR, TAN, TOD, TRN
- 3 **
- 4 –(negate), NOT
- 5 *, /, MOD
- 6 <, <=, >, >=, =, <>
- 7 –(subtract), +(add)
- 8 AND
- 9 XOR
- 10 OR

Strings can be compared in an expression. Strings are equal if their characters match. The hexadecimal values of the characters determine the value of one compared to another.

List of possible Operators for strings

- = equals
- < less than
- <= less than or equal
- > greater than
- >= greater than or equal
- <> not equal

List of possible arguments

**SINT PRE DEFINED STRUCTURE****INT PRE DEFINED STRUCTURE****DINT PRE DEFINED STRUCTURE****REAL PRE DEFINED DATA TYPE****STRING PRE DEFINED DATA TYPE**

** **

*Note: **Not all advanced operands are available in safety routines.*