Not equal to
The simplest way to say 'everything but'
- first
- second
- result
Not equal to is the "everything but this one thing" comparison, and it's shockingly useful once you notice. Two numbers in, and true whenever they're different. It's how you say "if this isn't the default, do the special thing" without enumerating every alternative - a != covers a universe of cases in one shot. It's the simplest form of exception handling a workflow can have.
It's from marco-zanella's ComfyUI-BooleanExpression pack, the dependency-free logic collection. It's the arithmetic mirror of the string-side "Not equal to", and it shares the exact same two-numbers-in, boolean-out anatomy as its siblings.
The inputs
Two required inputs, both INT or FLOAT:
first- the first number (default 0)second- the second number (default 0)
Output is result, a BOOLEAN: first != second. One Python comparison, nothing else. Wire result into a Conditional Branch and you've got "anything other than X takes the alternate path."
The patterns that make it worth having:
- "Is this the default?" - check whether a step count, seed, or CFG deviated from a sentinel value, and branch accordingly.
- Model or sampler routing - "if the batch index isn't 0, use the refinement settings."
- A cheap stand-in for "not this exact config." When you have exactly one case to exclude,
!=is clearer than an And of several==checks.
Installing it
No models, no dependencies, pure Python - the pack's requirements.txt is empty. ComfyUI Manager, search ComfyUI-BooleanExpression, or:
cd ComfyUI/custom_nodes
git clone https://github.com/marco-zanella/ComfyUI-BooleanExpression.git
Restart ComfyUI, and it's under Boolean Expressions → Arithmetic Comparisons.
Gotchas
- It shares the float trap with its sibling. Exact inequality is rock-solid for integers (steps, seeds, batch sizes) but can misfire on computed floats, where
0.1 + 0.2 != 0.3is famously true. If a "not equal" keeps firing when values look identical, it's IEEE floating point doing its thing - snap to integers or use range checks instead. - Fresh nodes read "0 != 0 → false" until you wire real values in, since both inputs default to 0. That's a "why is nothing happening" moment waiting to happen.
- Both branches downstream still compute. As with every comparison here, this just selects a value; the unselected chain upstream still runs. Free for numbers.
If you find yourself doing several different comparisons on the same two numbers, Binary Comparison in the same pack consolidates all six operators into a dropdown. But for a single "not this value" rule, this dedicated node reads clearest on a shared canvas.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| first | INT,FLOAT | 0 | The first number. |
| second | INT,FLOAT | 0 | The second number. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| result | BOOLEAN | — |