Nodes/ComfyUI-JakeUpgrade/Float Unary Condition JK๐Ÿ‰
ComfyUI Node

Float Unary Condition JK๐Ÿ‰

Is it NaN? Is it infinite? Ask a float directly

By jakechaiยทCreated 2 years agoยทUpdated 3 months agoยท 146
Float Unary Condition JK๐Ÿ‰
    • BOOLEAN
    โ—„opโ–พโ–บ
    โ—„a0.00โ–บ

    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.0 rare after any arithmetic; prefer IsNonZero with a threshold comparison (Gt/Lt in CM_FloatBinaryCondition) for "close to zero."
    • NaN never equals anything, including itself - but the IsNaN check is written explicitly, so it catches what an Eq comparison 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.
    Category๐Ÿ‰ JK/โœ–๏ธ Math/๐Ÿฅ Float

    Inputs (2)

    NameTypeDefaultDescription
    opCOMBOSelect unary condition to check
    aFLOAT0.00Input float value to check

    Outputs (1)

    NameTypeDescription
    BOOLEANBOOLEANโ€”