Nodes/yiu_comfy_nodes/.internal/math_int
ComfyUI Node

.internal/math_int

A two-operation integer calculator, built for loop indices

By leizingyiu·Created about a year ago·Updated 3 months ago· 1
.internal/math_int
    • value
    a0
    b0
    operation

    This is about as minimal as a node gets: two integers in, one integer out, and a dropdown that offers exactly two operations - add and subtract. No multiply, no divide, no modulo. That's not a deficiency; it's scope discipline. This node exists to be the loop counter inside the pack's hidden while-loop machinery, where all you need is "increment this by one each pass."

    It's an .internal node, so it's hidden from the node menu by the pack's front-end code. You'll meet it in saved workflows as the little thing that recomputes an index or a running total inside a loop body - the kind of value that has to be recalculated every iteration because it can't just sit in a widget.

    The range is generous (±999,999,999), which matters for upscaling math where step totals and pixel dimensions can get large, and the operation enum is explicit rather than a free-form expression - no parsing surprises, nothing to debug. If you need real arithmetic, reach for something with an expression evaluator; if you need a counter, this is it.

    Inputs

    • a - first integer.
    • b - second integer.
    • operation - add or subtract (defaults to add).

    Output

    value - a + b or a - b, as an INT.

    Installing it

    Part of yiu_comfy_nodes by leizingyiu:

    cd ComfyUI/custom_nodes
    git clone https://github.com/leizingyiu/yiu_comfy_nodes
    

    restart ComfyUI, and it's there (hidden) for anything that saves a workflow using it. No extra dependencies.

    Where people get burned

    • You can't add it from the menu. It's hidden on purpose. If a workflow loads with one, it just works - you don't need to find it.
    • Expecting multiply/divide. The dropdown only offers add and subtract. If you wire this in and wonder why there's no *, that's by design; the pack keeps a separate comparator node (__y_i_u__compare) for logic and this one for stepping.
    • Watch which side is the accumulator. subtract is a - b, not the absolute difference. In a loop, a is typically the running value and b the step.
    Category_yiu_nodes/internal

    Inputs (3)

    NameTypeDefaultDescription
    aINT0-999999999–999999999
    bINT0-999999999–999999999
    operationCOMBO2 options: add, subtract

    Outputs (1)

    NameTypeDescription
    valueINT