divide (zero safe)
The zero-safe division node
- FLOAT
Division in a node graph has an awkward secret: half the time the divisor is something a previous node computed, and "something a previous node computed" has a way of being zero when you least expect it. divide (zero safe) (Basic data handling: FloatDivideSafe) is the version of this pack's divide node that refuses to crash on that.
Same inputs - float1 and float2, both defaulting to 1 - and one FLOAT output. The difference is the zero policy. Normal case, it's plain float1 / float2. Divisor of zero? It returns infinity instead of throwing:
- positive numerator over zero →
inf - negative numerator over zero →
-inf 0 / 0→nan(not a number)
The mechanism is deliberate: float2 == 0.0 is caught and mapped to IEEE-754 infinity. Note the description says it assumes the zero is +0.0 - it doesn't try to preserve the sign of an actual -0.0 divisor, which is a level of pedantry you will almost certainly never care about.
Why you'd choose this over plain divide
Use FloatDivideSafe when a zero divisor is a legitimate possibility, not a bug. Classic example: normalizing by a count that comes from data, or computing a ratio where the denominator is a value you scraped from somewhere. If that denominator is sometimes zero, the safe version keeps the queue running instead of going red at 2am.
The trade-off is exactly what the previous paragraph implies: you're trading a crash for inf or nan flowing downstream. Those propagate silently. inf in a CFG or strength value can produce garbage output that looks like a valid image - just a wrong one. So the rule: safe division for values you know can be zero and have guarded downstream, plain divide when zero genuinely means something broke. If you're not sure which camp you're in, the loud crash of plain divide is often the more honest failure.
Installing it
Part of the Basic data handling pack by StableLlama. ComfyUI Manager → search "Basic data handling" → install → restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
then restart. No dependencies, no requirements.txt, no model downloads.
Troubleshooting
If you're getting weird results out of this node, check whether you're feeding 0 / 0 - you'll get nan, and nan never equals anything, which can silently break downstream comparisons. And as with all float math in this pack, remember the output is a FLOAT; 5 / 2 is 2.5, not 2.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| float1 | FLOAT | 1.00 | — |
| float2 | FLOAT | 1.00 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| FLOAT | FLOAT | — |