Nodes/KJNodes for ComfyUI/Int Operations
ComfyUI Node Runs on cloud

Int Operations

The loop's pocket calculator

By kijai·Created 3 years ago·Updated 2 days ago· 3,208
Int Operations
    • INT
    • BOOLEAN
    a0
    b0
    operation

    Loops run on arithmetic. Someone has to decrement the iteration counter, check whether it hit zero, compare accumulated frames against a target. In kijai's NativeLooping pack, that someone is _IntOperations - a dev-only node that takes two ints, a and b, applies one of a dozen operations, and outputs both an INT and a BOOLEAN. If you've ever expanded a TensorLoopClose workflow and wondered what all the little math nodes are doing, this is them.

    What it does

    The operation combo gives you the standard bag of tricks:

    • Arithmetic: add, subtract, multiply, divide, modulo, power
    • Comparisons: ==, !=, <, >, <=, >=

    Two details are worth knowing because they bite people. divide is integer division (a // b), which is what a loop wants when it's counting iterations - but guard against b being 0, because a divide-by-zero returns 0 rather than erroring, and a silent 0 can look like a legit result. Same for modulo: a % b returns 0 when b is 0. The comparisons are the ones you'll actually see in expanded workflows - "is remaining greater than 0?", "is accumulated count less than the frame target?" - and they're what drive the loop's continue/stop decision.

    The outputs

    Both outputs are always produced:

    • INT - the result, as an int (comparisons produce 0 or 1).
    • BOOLEAN - the same result cast to a boolean (so 0/False for a false comparison, 1/True for a true one).

    That dual output is the point of the design: you can feed the same operation into a math chain (as an int) and into a condition (as a boolean) without extra conversion nodes. In TensorLoopClose, for instance, the same comparison that decides whether the loop continues also feeds the start-trim math for the next iteration.

    Install

    Same drill as the rest of the pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/kijai/ComfyUI-NativeLooping_testing
    

    Restart ComfyUI, or grab it via Manager ("NativeLooping"). No requirements, no model files - just needs a current ComfyUI with the comfy_api.latest extension API.

    Honest framing: this is internal plumbing, not a node you'll add from the menu, and it's from a _testing repo - kijai's candidate for native ComfyUI loop nodes, per the README. If you need int math in your own workflows, plenty of dedicated utility packs do it with more polish and are worth a search. But if you're debugging a loop that's stopping a frame or two early or spinning forever, _IntOperations is where the counter logic lives, and the "divide by zero returns 0" behavior is the kind of thing that silently derails a loop. Check your divisors.

    Categoryadvanced/looping

    Inputs (3)

    NameTypeDefaultDescription
    aINT0-18446744073709550000–18446744073709550000
    bINT0-18446744073709550000–18446744073709550000
    operationCOMBO12 options: add, subtract, multiply, divide, modulo, power, +6

    Outputs (2)

    NameTypeDescription
    INTINT
    BOOLEANBOOLEAN