Compare — EQ / NE / GT / GE / LT / LE

Reference for Ladder Logic compare instructions in rungs.dev — EQ, NE, GT, GE, LT, LE — that pass power along a rung when the numeric relationship holds.

Compare two numeric values and pass power along the rung if the relationship holds. Compare instructions act like contacts — place them on the left side of a rung.

Available Compare Instructions

InstructionSymbolPurpose
EQ

EQ

Source A

sourceA

Source B

sourceB

Passes power when sourceA equals sourceB.
NE

NE

Source A

sourceA

Source B

sourceB

Passes power when sourceA does not equal sourceB.
GT

GT

Source A

sourceA

Source B

sourceB

Passes power when sourceA is greater than sourceB.
GE

GE

Source A

sourceA

Source B

sourceB

Passes power when sourceA is greater than or equal to sourceB.
LT

LT

Source A

sourceA

Source B

sourceB

Passes power when sourceA is less than sourceB.
LE

LE

Source A

sourceA

Source B

sourceB

Passes power when sourceA is less than or equal to sourceB.

Operands

NameType
sourceADINT | REAL
sourceBDINT | REAL

Compare instructions do not operate on BOOL — use XIC / XIO for boolean checks. That includes comparing two bits to each other: EQ / NE on a pair of BOOL tags is a compile error, because contacts already express the question. Put the combinations on parallel branches.

"Are the two bits different?" — one branch for each way they can disagree:

0

A

B

/

A

/

B

Different

"Are they the same?" — one branch for both-on, one for both-off:

0

A

B

A

/

B

/

Same

The same rule applies in Structured Text, where the answer is XOR.

Example — Temperature Alarm

Turn on a cooling fan when temperature exceeds the setpoint.

0

GT

Source A

Temperature

Source B

75

Fan

Example — Value in Range

Energize InRange only when Pressure is between 20 and 100 inclusive.

0

GE

Source A

Pressure

Source B

20

LE

Source A

Pressure

Source B

100

InRange

Practice

Try comparisons in the Sign Check exercise — flag whether a number is negative, zero, or positive.

Common Mistakes

  • Comparing a BOOL tag — use XIC / XIO instead.
  • Using EQ on REAL values — fragile due to floating-point rounding. Prefer GE / LE with a small tolerance, or LIMIT.

On this page