NumberBinaryOperationConditional
Guarded binary math that eats ints and floats alike — the NUMBER conditional for two operands
- NUMBER
NumberBinaryOperationConditional is the two-input member of ComfyMath's NUMBER family, and it's the most flexible guarded-math node in the pack: eleven binary operations on a and b, a boolean gate, and a fallback of a, b, or a constant when the gate is closed. Because the inputs are NUMBER rather than FLOAT, it happily accepts ints and floats without conversion nodes cluttering the graph.
The ops are the same eleven as the float binary node: Add, Sub, Mul, Div, Mod, Pow, FloorDiv, Max, Min, Log, and Atan2. Internally both operands get converted to float, the math runs, and a NUMBER comes out. So Div here is true float division (20 Div 80 → 0.25), not the floor division you get from the int binary node - a distinction that has burned more than one person switching between the two.
The guard is the point
The whole reason the conditional family exists is that math can misbehave and ComfyMath doesn't catch the errors. Float division by zero yields inf/nan rather than a crash - arguably worse, because the bad value sails downstream and poisons everything it touches. The conditional node is your explicit safety valve: gate Div on a b != 0 check from a binary condition node, set fallback_mode, and the dangerous case returns a sensible value instead of propagating garbage. Same logic applies to Log, which needs a positive base and a positive argument, and to Pow with sketchy exponents.
Inputs and output
- condition - BOOLEAN, default false.
- op - one of the eleven.
- a, b - NUMBER, default 0.0.
- fallback_mode -
A,B, orconstant. - fallback_value - NUMBER, default 0.0.
Output is a single NUMBER.
Caveats worth writing down
- NUMBER out ≠ INT out. The result is float-flavored. If the downstream socket insists on an integer, route through NumberToInt - which truncates toward zero, so
-3.7becomes-3. - Floating-point rounding.
1.1 + 0.1can be1.2000000000000002. The README is upfront about it. Don't write exact-equality logic on the result. Atan2order.ais y,bis x. Swap them and your angle lands in the wrong quadrant.
Installing it
It ships in ComfyMath, published as ComfyMath-NG. Install via ComfyUI Manager - search "ComfyMath" - or clone:
cd ComfyUI/custom_nodes
git clone https://github.com/rabanti-github/ComfyMath.git ComfyMath-NG
Restart ComfyUI. This fork registers the same node IDs as the original ComfyMath, so disable or remove the original first. Only dependency is numpy.
Verdict
If you're mixing ints and floats in one graph - which most real workflows are - this is the guarded-math node to reach for. The float-only version is fine, but the NUMBER variant removes a whole layer of conversion-node noise for no real downside.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| condition | BOOLEAN | false | — |
| fallback_mode | COMBO | 3 options: A, B, constant | |
| fallback_value | NUMBER | 0 | — |
| op | COMBO | 11 options: Add, Sub, Mul, Div, Mod, Pow, +5 | |
| a | NUMBER | 0 | — |
| b | NUMBER | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| NUMBER | NUMBER | — |