Nodes/ComfyMath/IntUnaryCondition
ComfyUI Node

IntUnaryCondition

Quick true/false checks on a single integer

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

    You'll usually meet this one when you're wiring up something that needs to behave differently depending on a single number - a loop counter, a batch index, a seed offset. IntUnaryCondition takes one integer, runs a check against it, and outputs true or false. It's the single-value sibling of CM_IntBinaryCondition (which compares two numbers), both part of ComfyMath, evanspearman's boolean/math/vector utility pack for ComfyUI.

    How it works

    Pick an op from six choices - IsZero, IsNonZero, IsPositive, IsNegative, IsEven, IsOdd - and feed it a, your integer. The node runs that one test against a and returns the result. IsEven and IsOdd are the ones that come up more than you'd expect once you're building anything loop-shaped: gate a node to only fire on every other frame, alternate between two branches based on a counter's parity, that kind of thing. IsZero/IsNonZero and IsPositive/IsNegative are the more generic sanity-check pair - catching a value that dropped to zero (or went negative) before it hits a node that would choke on it.

    Inputs and outputs

    • op - the condition to test (IsZero, IsNonZero, IsPositive, IsNegative, IsEven, IsOdd).
    • a (INT, default 0) - the value being tested.
    • Output: BOOL - ComfyMath's own boolean type, not ComfyUI's built-in BOOLEAN.

    How to install it

    Through ComfyUI Manager: search ComfyMath, install, restart. Manually, from your custom nodes folder:

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

    then restart ComfyUI. No dependencies to install, no models to download - it's self-contained Python, so there's nothing else to configure.

    Common issues & troubleshooting

    The BOOL output won't connect to a switch/If node from another pack. This node outputs BOOL, which is ComfyMath's own custom type - it isn't the same as ComfyUI's native BOOLEAN. A lot of gate/switch nodes elsewhere in the ecosystem specifically want BOOLEAN. If a connection refuses to snap, that's usually why, not a bug. CM_IntToBool outputs the native BOOLEAN type instead, if that's what you actually need (it only tests for nonzero, though, not the full condition list here).

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

    Not sure the check ran correctly. This node has no visual output of its own - drop a text/preview node on the BOOL output, or temporarily route it into something that displays the value, while you're building and debugging the logic.

    It's an old, largely unmaintained pack. A 2024 community thread noted the ComfyMath author had stepped away from active development. In practice this matters very little for a pack that's just doing integer comparisons in plain Python - there's no external dependency to go stale, and it's simple enough that it hasn't needed fixes. Don't expect the operator list to grow, but don't expect it to break either.

    Categorymath/int

    Inputs (2)

    NameTypeDefaultDescription
    opCOMBO6 options: IsZero, IsNonZero, IsPositive, IsNegative, IsEven, IsOdd
    aINT0

    Outputs (1)

    NameTypeDescription
    BOOLBOOL