Float Unary Condition JK๐
Is it NaN? Is it infinite? Ask a float directly
- BOOLEAN
CM_FloatUnaryCondition asks a single float a yes/no question and returns a BOOLEAN. The op dropdown has eleven questions: IsZero, IsPositive, IsNegative, IsNonZero, IsPositiveInfinity, IsNegativeInfinity, IsNaN, IsFinite, IsInfinite, IsEven, IsOdd.
The two that are worth the most column inches are IsNaN and IsFinite - because those are the ones that save your run.
The NaN guard
Denoising pipelines occasionally cough up a nan or inf - a bad VAE decode, a division by a near-zero denoiser, a sampler edge case. The failure mode isn't a helpful error; it's a silently black image or a crash three nodes later. Wiring IsNaN (or the inverse, IsFinite) after any float-producing step turns "garbage value" into a boolean you can branch on: retry with a different seed, clamp the value, or skip the bad path. It's the cheapest insurance a graph can buy, and almost no stock ComfyUI install ships it.
The other operators are the float-world versions of the integer conditions: IsZero/IsNonZero for "did anything come through," IsPositive/IsNegative for direction checks. IsEven/IsOdd work on floats here by testing the remainder - fine for whole-valued floats, meaningless for 0.3, so don't lean on them.
Installing it
Ships with ComfyUI-JakeUpgrade:
cd ComfyUI/custom_nodes
git clone https://github.com/jakechai/ComfyUI-JakeUpgrade
cd ComfyUI-JakeUpgrade
# Windows standalone: install.bat
# or: python_embeded\python.exe -s -m pip install -r requirements.txt
pip install -r requirements.txt # non-Windows
Or ComfyUI Manager, search "JakeUpgrade", install, restart.
Gotchas
- IsZero on computed floats is a trap. Floating-point math makes exact
== 0.0rare after any arithmetic; preferIsNonZerowith a threshold comparison (Gt/Lt in CM_FloatBinaryCondition) for "close to zero." - NaN never equals anything, including itself - but the
IsNaNcheck is written explicitly, so it catches what anEqcomparison would miss. That's exactly why this node exists. - Manager's JakeUpgrade / IPAdapter_plus conflict warning is a false positive from the pack's
replacement/folder. - ComfyUI-MultiGPU causes CUDA errors with recent ComfyUI - disable it per the README.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| op | COMBO | Select unary condition to check | |
| a | FLOAT | 0.00 | Input float value to check |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| BOOLEAN | BOOLEAN | โ |