ComfyUI Node

Integer Math

Arithmetic on integers, with a human-readable receipt

By turnbros·Created 11 months ago·Updated 10 months ago· 0
Integer Math
    • result
    • expression
    operationadd
    a0
    b0

    Integer Math is a two-operand calculator for whole numbers, and its hidden superpower is that it tells you what it did. You pick an operation, feed it a and b, and it returns the numeric result plus an expression string like 8 × 4 = 32. That expression output is easy to underrate, but in a debugging session it's gold - you can wire it into a text display and see exactly what arithmetic ran, instead of squinting at a bare number wondering where it came from.

    When do you actually need math in a diffusion graph? More often than you'd think. Seed transforms (seed + 1 for a variation series), step math, batch-size arithmetic, frame counts for video, dimension tricks - the patterns show up constantly once you start building anything that loops or varies. This node covers the six operations that matter for that: add, subtract, multiply, divide, modulo, and power.

    The inputs that matter

    operation is a dropdown with the six listed above. a and b are INTs in the signed 32-bit range, and both accept wired inputs - so you can chain arithmetic nodes together ((a + b) * c by feeding one result into the next a). The one behavior to know before you hit it by accident: divide is integer division. 7 ÷ 2 gives you 3, not 3.5. If you need decimals, this isn't the node - it's integer math, as advertised. And divide or modulo by zero raises an error rather than silently doing something weird, which is the right call for a debugging-friendly pack.

    Outputs

    • result - an INT, the numeric answer. Wire this into anything that takes an integer.
    • expression - a STRING like 5 % 2 = 1. The debugging receipt. Plug it into a Show Text or note node and you can see every computation a workflow performed.

    Installing it

    ComfyBros installs like any custom node pack - ComfyUI Manager, search "ComfyBros", install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/turnbros/ComfyBros
    

    Then restart ComfyUI. The README references a requirements.txt that doesn't exist; real deps are in pyproject.toml (pillow, numpy, requests) and Manager handles them. Integer Math lives under ComfyBros/Math.

    Gotchas

    Integer division catching you off-guard is the main one. If you divide and the number comes back looking "wrong," check whether you wanted a float. Otherwise this node is about as predictable as it gets - pick an op, feed two integers, get an integer and a readable receipt.

    CategoryComfyBros/Math

    Inputs (3)

    NameTypeDefaultDescription
    operationCOMBOadd6 options: add, subtract, multiply, divide, modulo, power
    aINT0-2147483648–2147483647
    bINT0-2147483648–2147483647

    Outputs (2)

    NameTypeDescription
    resultINT
    expressionSTRING