ComfyUI Node

Compare Int

Gating workflows on a number

By danipisca07·Created 6 months ago·Updated 6 months ago· 0
Compare Int
    • BOOLEAN
    a0
    b0
    op

    Integers are the coins of ComfyUI - seeds, step counts, batch sizes, widths, heights - and SL_CompareInt is the node that turns a relationship between two of them into a boolean you can act on. Pick an operator from the dropdown (==, !=, >, <, >=, <=), wire in two integers, and out comes True or False. That boolean is what conditional branches are built from.

    This is the workhorse of "should I do the thing" decisions that hinge on discrete values: "if steps exceed 30, run the second pass," "if the seed is even, use the other prompt," "if batch index passed N, stop." It's the integer twin of SL_CompareFloat, and for integers it's actually the safer of the two - no floating-point precision traps, because whole numbers compare exactly. == on integers means exactly what you think it means.

    The mechanism is a dictionary lookup mapping the operator to a Python comparison. Nothing hidden: >= is >=, the result is a plain boolean.

    Inputs:

    • a (INT) - first value, default 0
    • b (INT) - second value, default 0
    • op - dropdown with the six comparison operators
    • Output: BOOLEAN - the comparison result

    The operator is chosen once on the node's config panel, not via a wire. You get one clean comparison per node; for multiple conditions you chain them through logic nodes like SL_AND.

    Installing it

    Part of ComfyUI-SimpleLogics. Manager → search "SimpleLogics" → install → restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/danipisca07/ComfyUI-SimpleLogics
    

    Restart, Add Node → search "Compare Int" (menu group SimpleLogics/Compare). Zero dependencies, no downloads.

    Where it shows up

    • Seed and step gating: branch on whether a seed or step count crossed a line - the classic "only do the second upscale when steps > 30" pattern.
    • Loop/counter guards: in batch or iteration workflows, compare an index against a bound and stop or switch when it's reached.
    • Feeding switch nodes: the boolean output drives SL_SwitchInt, SL_SwitchString, or SL_SwitchAny to pick which branch's value flows onward.

    Gotchas

    • INT is a strict input. If you're coming from a FLOAT source, you'll hit a red link - run it through SL_FloatToInt (or SL_NumberToInt) first. Note the reverse is friendly: this node can't take floats, but SL_CompareFloat happily accepts INT wires if your values are already whole.
    • Two fixed inputs, one operator. For a range check like "5 < x < 20," you need two Compare nodes ANDed together. This one does a single relationship per node.
    • Defaults of 0: an unwired a or b silently compares against 0.

    There's no magic here, and that's the point. When you want a workflow that actually decides things based on its own numbers, Compare Int is the hinge everything else swings on.

    CategorySimpleLogics/Compare

    Inputs (3)

    NameTypeDefaultDescription
    aINT0
    bINT0
    opCOMBO6 options: ==, !=, >, <, >=, <=

    Outputs (1)

    NameTypeDescription
    BOOLEANBOOLEAN