Nodes/ComfyMath/NumberUnaryCondition
ComfyUI Node

NumberUnaryCondition

Test one generic number, get true or false

By evanspearman·Created 3 years ago·Updated about a year ago· 192
NumberUnaryCondition
    • BOOL
    op
    a0

    Same idea as CM_FloatUnaryCondition, just working on ComfyMath's own generic NUMBER type instead of a committed FLOAT. NumberUnaryCondition tests one value against a condition and hands back true or false - useful when you're mid-chain through several of ComfyMath's Number* nodes and don't want to cast to a concrete int or float just to run a check.

    It's part of ComfyMath, evanspearman's boolean/int/float/vector utility pack for ComfyUI, and it fills the "is this value in a weird state" gap that comes up whenever you're doing real arithmetic inside a graph rather than just wiring models together.

    How it works

    Pick an op from eleven choices - IsZero, IsPositive, IsNegative, IsNonZero, IsPositiveInfinity, IsNegativeInfinity, IsNaN, IsFinite, IsInfinite, IsEven, IsOdd - and feed it a, your NUMBER value. The node runs that single check and outputs a boolean.

    The NaN/infinity checks are the most practically useful ones if you're chaining several math operations together upstream: a divide-by-zero or a bad log call several nodes back doesn't crash anything, it just quietly turns into NaN or infinity and keeps flowing until it causes a confusing failure somewhere downstream. Dropping an IsNaN or IsFinite check right after a calculation you're not fully sure about catches that early instead of debugging it blind later.

    Inputs and outputs

    • op - the condition to test (the eleven listed above).
    • a (NUMBER, default 0) - the value being tested.
    • Output: BOOL - ComfyMath's own boolean type.

    How to install it

    Through ComfyUI Manager: search ComfyMath, install, restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/evanspearman/ComfyMath.git
    

    then restart ComfyUI. It's plain Python, no dependencies, no models to fetch.

    Common issues & troubleshooting

    It won't connect to a value coming from a core INT or FLOAT node. NUMBER is ComfyMath's own type, distinct from core ComfyUI's INT and FLOAT. If you're starting from a plain INT or FLOAT value, either use the INT/FLOAT-specific condition node instead (CM_IntUnaryCondition, CM_FloatUnaryCondition), or convert into a NUMBER-typed chain first if you're planning to do several ComfyMath operations in a row.

    Output won't plug into a switch/If node expecting boolean. This node's BOOL output is ComfyMath's own type, not core ComfyUI's BOOLEAN. If you need the native type, check whether CM_IntToBool (which does output BOOLEAN, but only tests for nonzero) fits your case instead.

    Missing node error on a shared workflow. Install ComfyMath via Manager as above, then reload.

    The pack looks unmaintained. A 2024 community thread flagged that the author had stepped back from active development. Fine for a pack this small and dependency-free - there's little for a ComfyUI update to actually break here, so treat it as a stable, finished utility rather than an actively evolving one.

    Categorymath/Number

    Inputs (2)

    NameTypeDefaultDescription
    opCOMBO11 options: IsZero, IsPositive, IsNegative, IsNonZero, IsPositiveInfinity, IsNegativeInfinity, +5
    aNUMBER0

    Outputs (1)

    NameTypeDescription
    BOOLBOOL