Nodes/Comfyui-PixNodes/Math Integer (PixNodes)
ComfyUI Node

Math Integer (PixNodes)

Integer math without leaving the graph

By pixixai·Created 8 months ago·Updated 6 months ago· 24
Math Integer (PixNodes)
    • result
    a0
    b0
    operation

    Every workflow eventually needs arithmetic on its own numbers: a batch count that needs doubling, a step number to offset, a seed to derive from another seed. Math Integer is the two-input calculator for that - a and b, six operations, one integer out. It's the most basic node in the pack's Logic category, and it's useful precisely because it doesn't try to be anything else.

    You'll reach for it when you want integer math that stays integer. The whole point of this node over a generic math node is that both inputs and the result are typed INT, so the output feeds an INT port (like a loop index or a batch size) without a type conversion detour.

    The operations

    a, b (both INT) and an operation dropdown:

    • add, subtract, multiply - unsurprising, exact.
    • divide - integer division (a // b), so 7 / 2 gives 3, not 3.5. The fraction is thrown away.
    • modulo - the remainder, 7 % 31. This is the one you'll actually build logic with (wrap-around indexing, even/odd checks).
    • power - a ** b. Careful: big exponents blow up fast.

    The output is a single result (INT).

    Where it actually earns its keep

    The realistic uses are plumbing, not science. Deriving a second seed from a base seed (base + offset), computing a tile count from a grid (horizontal * vertical), computing the number of batches from a total and a batch size (integer division, then check the remainder with modulo to see if there's a partial batch left). It's also a good citizen in the pack's loop system - feed loop indices through it to compute positions or scaled values before they hit a node that needs an integer.

    Install

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

    cd ComfyUI/custom_nodes
    git clone https://github.com/pixixai/Comfyui-PixNodes
    

    then restart. (The README's manual-install line pastes the wrong repo URL, ComfyUI-AlignLayout - use the one above.) No models, no extra deps.

    The honest caveats

    Integer division truncates, not rounds - if you expect 7 / 2 == 3.5, you're in the wrong node (this one gives 3), and a // b rounds toward zero for negatives. The bigger trap is divide by zero: it returns 0 silently instead of erroring, so a bad b won't turn the node red, it'll just quietly poison the downstream math. If you've got a value that can legitimately be zero, guard it before it reaches here. For everything else - the simple, deterministic integer arithmetic this node is built for - it's hard to beat a node that has exactly two knobs and one answer.

    CategoryPixNodes/Logic

    Inputs (3)

    NameTypeDefaultDescription
    aINT0-18446744073709550000–18446744073709550000
    bINT0-18446744073709550000–18446744073709550000
    operationCOMBO6 options: add, subtract, multiply, divide, modulo, power

    Outputs (1)

    NameTypeDescription
    resultINT