Nodes/DD-LogicNodes/DD Number Compare
ComfyUI Node

DD Number Compare

Turning a number into a yes/no you can wire

By dumbdemon·Created 6 months ago·Updated a day ago· 0
DD Number Compare
  • numA
  • numB
  • *
compare_type==

ComfyUI has spent years pretending not to be a programming language. You have samplers, loaders, and twelve kinds of latent math, but the moment you want "if the image is wider than 1024, take this path instead", you're stuck - because a width is a number and a branch needs a boolean, and nothing in core converts one into the other.

DD Number Compare is exactly that converter. Two numbers go in, a TRUE/FALSE comes out. That's the whole node, and for what it does, that's the point.

Why a comparator is a real gap

Every workflow is mostly plumbing - value nodes, switches, reroutes - and people have asked for logic gates in core for years. A 2024 r/comfyui thread called "Do logic gate nodes exist?" got answers pointing at rgthree's Any Switch, Impact Pack's Bridge Control, and cubiq's math nodes: demand real, supply scattered. Even in 2026 the core Switch node is still marked experimental (is_experimental=True in comfy_extras/nodes_logic.py), and users are still grumbling that a vanilla install "has to change a setting or install a custom node pack to get a boolean switch."

So the boolean side got partially filled in. The arithmetic side - comparing two numbers - is where DD-LogicNodes picks up, and it's the node that lets the number drive the branch instead of you eyeballing a resolution and flipping a widget by hand.

How it works

It's about as simple as a node gets, and I mean that as praise. The class is NumberCompare in src/dd_logicnodes/logicGates.py, registered as node id DDNumberCompare. It runs one Python comparison and hands back the result as a boolean:

if compare_type == "==":  return io.NodeOutput(numA == numB)
if compare_type == ">":   return io.NodeOutput(numA > numB)
if compare_type == "<":   return io.NodeOutput(numA < numB)
if compare_type == "<=":  return io.NodeOutput(numA <= numB)
return io.NodeOutput(numA >= numB)   # >=

No float coercion, no rounding, no tolerance. Whatever arrives gets compared and the answer goes out.

The inputs and output that matter

  • numA and numB - the two things being compared. Both are match-type sockets restricted to INT and FLOAT, sharing one match template so the graph treats them as the same kind of number. These are sockets, not widgets: there's no box to type 1024 into. Feed them from a PrimitiveInt/PrimitiveFloat, from Get Image Size (which outputs width, height, batch_size as ints), or off a converted widget upstream.
  • compare_type - the operator, shown in the UI as "Compare". Five options: ==, >, <, >=, <=. Default is ==.
  • Output: one boolean, named *. Wire it into anything expecting a BOOLEAN.

That output is where the fun starts. It drops straight into the expression input of the pack's own getters - DD Or Getter, DD And Getter, DD NAND Getter and friends - which take a boolean plus an on_true and on_false and pass one of them through. That's your if/else: compare the width, let the getter hand the sampler one thing or the other. It also plugs into the boolean switch input on core's experimental Switch, into rgthree's switches, or into an Impact Pack Bridge Control when you'd rather mute a whole branch than pick a value.

Install

The README is a node list and nothing else, so here's the real path. It's on the Comfy Registry (PublisherId = "dumbdemon", DisplayName = "DD-LogicNodes" in pyproject.toml), so in ComfyUI Manager just search DD-LogicNodes. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/dumbdemon/DD-LogicNodes
# then restart ComfyUI

The good news: zero dependencies. dependencies = [], no models, no pip step, nothing to download. Clone and restart. Because it registers as a V3 extension via comfy_entrypoint(), you won't find it by grepping for NODE_CLASS_MAPPINGS - that's normal for newer packs, not a sign of breakage.

Where people get burned

The pack needs a recent ComfyUI. It imports from comfy_api.latest import ComfyExtension, io and subclasses io.ComfyNode - the V3 backend authoring API. On an older install that import fails and the pack loads nothing: no nodes under DD Logic Nodes/Logic Gates, just a traceback in the console if you scroll for it. Update ComfyUI before you start debugging the pack itself.

Don't use == on floats. numA and numB accept floats happily, and floats are rarely exactly what you think - a computed scale or resized dimension lands on 1023.9999, not 1024, and == says false with a straight face. For anything derived from image math, reach for >= or <=; save == for ints like seeds, batch sizes, and frame counts.

Empty sockets are the other classic. Because numA/numB have no widget defaults, a fresh node sits there doing nothing until both are connected. If your downstream switch never fires, check that both numbers are actually wired - an unconnected comparison isn't a subtle failure, it just doesn't run.

CategoryDD Logic Nodes/Logic Gates

Inputs (3)

NameTypeDefaultDescription
numACOMFY_MATCHTYPE_V3
numBCOMFY_MATCHTYPE_V3
compare_typeCOMBO==5 options: ==, >, <, >=, <=

Outputs (1)

NameTypeDescription
*BOOLEAN