ComfyUI Node

Integer Subtract

Subtract integers inside a ComfyUI workflow

By jamesWalker55·Created 3 years ago·Updated about a year ago· 215
Integer Subtract
    • INT
    a0
    b0

    JWIntegerSub does a - b on two integers and returns an integer. Whole numbers only, in and out. It's the integer version of JWFloatSub, and you use it wherever the thing you're computing has to stay a genuine whole number.

    That's more places than it sounds. Frame indices, step counts, batch sizes, pixel offsets - these are all integers, and mixing a float into them either errors or forces you to add a conversion node. Doing the subtraction in integer space keeps the result the right type for those slots. The everyday example: figuring out how many frames or steps are left. Total minus done. Or computing an offset - this index minus that one - to line up two sequences.

    Like all the little math nodes in James Walker's pack, the value is that the arithmetic lives in the graph. Wire a and b from upstream nodes and the difference recomputes every run. Change the total and "remaining" follows, no manual edit.

    What it actually does

    a minus b, both INT, one INT out. Both default to 0, and the range spans a full 64-bit integer (roughly ±1.8e19) - far past anything you'll ever need. The result can absolutely go negative if b is larger than a; the node won't stop it.

    The inputs and outputs that matter

    Two required inputs, one output:

    • a - the value you subtract from (INT).
    • b - the value you subtract (INT).

    Output: a single INT equal to a - b. Feed it into a frame count, an index, a batch size, or the next node in a math chain.

    How to install it

    The pack is jamesWalker55/comfyui-various. ComfyUI Manager: search Various ComfyUI Nodes by Type, install, restart. Or clone:

    cd ComfyUI/custom_nodes
    git clone https://github.com/jamesWalker55/comfyui-various
    

    then restart. No dependencies. Prefer to stay lean? Drop just comfyui_primitive_ops.py into custom_nodes/ - every Integer and Float node lives in that one file, so you get the arithmetic without cluttering your node list with the pack's image and mask nodes.

    Common issues & troubleshooting

    Negative results. a - b will go below zero the moment b exceeds a. If a negative frame count or index is breaking a downstream node, clamp the result with JWFloatMax (floor it at 0) - or reconsider which input is which, since a - b is not b - a.

    Wrong number type downstream. If you needed the difference as a float, this node hands you an int. Convert it with the pack's integer-to-float node. Conversely, if a node insists on an integer and you're passing a float, this is the node that keeps you honest.

    CategoryjamesWalker55

    Inputs (2)

    NameTypeDefaultDescription
    aINT0-18446744073709550000–18446744073709550000
    bINT0-18446744073709550000–18446744073709550000

    Outputs (1)

    NameTypeDescription
    INTINT