FloatBinaryOperationConditional
Guarded two-float math — Add, Div, Max, Log and Atan2 that only run when you say so
- FLOAT
The binary conditional node is the workhorse of ComfyMath's guarded-operation family. You get eleven binary float operations on a and b, gated by a boolean - and when the gate is closed, the node returns a, b, or a constant instead of doing the math. It's the difference between a workflow that occasionally crashes and one that just shrugs and continues.
The single most valuable pattern in the whole pack lives here: guarded division. Div of a float by zero doesn't raise in Python - it gives you inf or nan - which is arguably worse than a crash because nan then silently poisons every downstream node. The conditional node lets you write the guard explicitly: an IntBinaryCondition/FloatBinaryCondition Neq on b vs 0 feeds condition, op = Div, and the fallback returns something sane. No infinities, no NaNs, no mystery outputs.
The eleven ops
- Arithmetic:
Add,Sub,Mul,Div,Mod,Pow,FloorDiv - Selection:
Max,Min - Specialty:
Log(logarithm ofawith baseb),Atan2(angle from the coordinatesa, b)
Worth knowing the distinction between Div and FloorDiv: Div is true float division (20.0 Div 80.0 → 0.25), while FloorDiv divides and rounds down (20.0 FloorDiv 80.0 → 0.0). They diverge the moment remainders appear, so pick deliberately. And Mod is the remainder - 100.0 Mod 80.0 → 20.0 - handy for cyclic value ramps.
Inputs and output
- condition - BOOLEAN, default false. The gate; true means do the op.
- op - one of the eleven.
- a, b - FLOAT inputs, step 0.001.
- fallback_mode -
A,B, orconstant. - fallback_value - FLOAT, default 0.0, only used with
constant.
Output is a single FLOAT.
Where people get burned
Logdomain.amust be positive andbmust be positive and not 1, or you getnan/errors. If your bases can drift, gate on positivity checks.Powand precision. Float powers are fine, but remember the IEEE 754 reality the README flags:1.1 + 0.1can land on1.2000000000000002. Don't build exact-equality logic on float outputs.Atan2argument order. It'saas y,bas x (the classic two-argument atan), so swapping the inputs flips the quadrant of your angle. The README example1.0 Atan2 1.0→π/4is the one to memorize.
Installing it
It's part of 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 reuses the original ComfyMath's node IDs, so disable or remove the original first. The only dependency is numpy - nothing heavy to download.
The takeaway
The conditional variants cost you nothing over the plain operation nodes - same op lists, same math, one extra boolean socket. Once you've been bitten by a silent nan flowing through an unguarded divide, you stop using the plain version entirely. Start here.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| condition | BOOLEAN | false | — |
| fallback_mode | COMBO | 3 options: A, B, constant | |
| fallback_value | FLOAT | 0.000 | — |
| op | COMBO | 11 options: Add, Sub, Mul, Div, Mod, Pow, +5 | |
| a | FLOAT | 0.000 | — |
| b | FLOAT | 0.000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| FLOAT | FLOAT | — |