Nodes/ComfyUI Easy Use/easy mathInt
ComfyUI Node Runs on cloud

easy mathInt

Integer arithmetic inside your workflow

By yolain·Created 3 years ago·Updated 8 days ago· 2,633
easy mathInt
    • INT
    a0
    b0
    operation

    Takes two integers, does one arithmetic operation on them, hands back an integer. It's a calculator node, and the reason you want a calculator inside a node graph is that hard-coding derived numbers is how workflows quietly break. If your upscale pass should run at exactly twice the width of the source, you don't want to type "2048" and hope the source stays 1024 - you want to compute it, so the relationship holds when the input changes. easy mathInt is that computation.

    Why you'd reach for it

    The classic case is dimensions. Grab an image's width with a size node, multiply by 2 with easy mathInt, feed the result to your hires pass - now the math follows the source automatically. Halve a dimension for a downscale, add padding, divide a batch into chunks; all of it is "read a number, transform it, pass it on," and that's exactly this node.

    The other big case is driving loops. The for-loop and index-switch nodes in this pack think in integers, and you frequently need to derive the count or the index rather than type it - total frames divided by a stride, an index offset by one, a step count scaled by some factor. easy mathInt is the arithmetic glue between the value you have and the value the loop needs.

    Because it stays in integer-land, there's no float drift and no surprise decimals arriving at a socket that only wants whole numbers - which is precisely what dimensions, counts, and indices want.

    The inputs and outputs

    Three inputs, one output:

    • a and b (INT) - the two operands. Both accept a very large range, so you're not going to overflow on any realistic generation math. Type them, or wire them from other nodes (an easy imageSize output, an easy int, a loop index).
    • operation - the operation to apply between a and b (the standard arithmetic set). Pick it from the dropdown.
    • INT (output) - the result, as a proper integer ready for any int socket.

    Wire real values into a and b and the node becomes a live relationship rather than a static number - change the input, the output recomputes.

    Installing it

    ComfyUI Manager: search ComfyUI Easy Use, install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/yolain/ComfyUI-Easy-Use
    

    then install the requirements (install.bat on Windows, else pip install -r ComfyUI-Easy-Use/requirements.txt) and restart. Nothing else needed.

    Common issues

    • Integer division truncates. Divide 7 by 2 and you get 3, not 3.5 - the fractional part is dropped, because the output is an integer by design. That's usually what you want for counts and indices, but if you were expecting a rounded or exact result, that's the reason for the discrepancy. For fractional math you want a float math node instead.
    • Watch out for divide-by-zero. If b can be driven to 0 by an upstream node, a division operation is going to error. When b comes from something dynamic, make sure it can't hit zero, or guard it.
    • It's integer-only end to end. Feeding it a float-shaped value or expecting a float back won't work here - this node is the whole-number specialist. Keep it on dimensions, counts, and indices, and it's completely predictable.
    CategoryEasyUse/Logic/Math

    Inputs (3)

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

    Outputs (1)

    NameTypeDescription
    INTINT