ComfyUI Node

Compare

Turn numbers into booleans for your IF node

By silveroxides·Created 7 months ago·Updated 3 months ago· 3
Compare
  • value_a
  • value_b
  • result
comparisonEqual

Compare is the node that turns a number into a decision. It takes two values, value_a and value_b, lets you pick a comparison from a dropdown - Equal, Not Equal, Greater Than, Less Than, Greater Than or Equal, Less Than or Equal - and returns a single boolean: did the comparison hold? This is the bridge between "math" and "logic" in this pack, and it's the input node for nearly every conditional workflow you'll build.

Think of the flow: some calculation produces a number, Compare turns it into a true/false, and LogicIF uses that boolean to route the graph down one branch or another. "If the resolution is greater than 1024, upscale, else skip." "If the CFG value equals 7, use this sampler, else that one." "If the denoise is at least 0.6, do the detail pass." Every one of those is a Compare feeding a LogicIF. Compare nodes are also how you build the checks that gate whole sections of a workflow behind a condition - the backbone of workflows that make real decisions.

How it works

The mechanism is a plain Python comparison executed on the chosen comparison option. The inputs accept ints or floats via the type template, the comparison is a dropdown defaulting to Equal, and the output is always a BOOLEAN.

Two things are worth knowing. First, "Equal" on floats can be a subtle trap - if a value comes out of a calculation, floating-point rounding can make what should be 1.0 land as 1.0000000002, and Equal returns false. If you're comparing computed values for equality, prefer a range check (greater-than-or-equal on one side, less-than on the other) or compare after rounding. Second, the comparison is strict about types in the intuitive way: comparing an int and a float works fine (Python handles it), but the output is always boolean, so the result wires cleanly into logic nodes.

The inputs that matter

  • value_a - the left side of the comparison.
  • value_b - the right side.
  • comparison - the operator, one of the six options (default Equal).

Output is result, a BOOLEAN - wire it into LogicIF, AND/OR/NOT, or a switch.

Install

This node ships in the ComfyUI-LogicMath pack. Install via ComfyUI Manager (search "ComfyUI-LogicMath", Install, restart) or:

cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-LogicMath

No pip dependencies, no model files. The pack targets ComfyUI's newer extension API, so update ComfyUI if the node doesn't appear.

Common issues

  • "Equal" says false for equal numbers - float rounding on computed values; use a range check instead of exact equality.
  • Nothing downstream responds - check that the boolean output is actually wired to the decision node; a Compare that outputs into a dead wire is the classic silent failure.

Compare is the node that makes all the pack's logic worthwhile - it's how raw numbers become decisions, and decisions are what turn a linear workflow into one that can route itself.

Categoryutils/math

Inputs (3)

NameTypeDefaultDescription
value_aCOMFY_MATCHTYPE_V3
value_bCOMFY_MATCHTYPE_V3
comparisonCOMBOEqual6 options: Equal, Not Equal, Greater Than, Less Than, Greater Than or Equal, Less Than or Equal

Outputs (1)

NameTypeDescription
resultBOOLEAN