Nodes/ComfyUI GOAT Nodes/🐐 Int Divide (Rounded)
ComfyUI Node

🐐 Int Divide (Rounded)

Division that gives you back an integer, not a float you have to clean up

By AconexOfficialΒ·Created 2 years agoΒ·Updated 12 months agoΒ· 11
🐐 Int Divide (Rounded)
    • INT
    β—„aβ€”β–Ί
    β—„bβ€”β–Ί

    Plain division of two integers in most programming contexts gives you a float, which is exactly the kind of thing that trips up a ComfyUI graph - plug 1024 / 3 into a node that expects a whole-number width or batch size, and you'll either get an error or a silent implicit floor you didn't ask for. Int Divide (Rounded) exists for the boring but common case where you need a / b and you need the result to be a proper integer, rounded to the nearest whole number rather than truncated.

    How it works

    Two integer inputs, one division, rounded to the nearest int on the way out - that's the entire node. It's the kind of tiny utility that earns its place in a math-heavy graph (splitting a total pixel budget across a number of tiles, computing a batch size from a total divided by a group count, that sort of thing) purely by saving you from wiring up a generic math-expression node and remembering the right rounding syntax every time.

    Inputs and outputs that matter

    • a (INT) - the numerator.
    • b (INT) - the denominator.

    One output: INT - a / b, rounded to the nearest whole number.

    How to install it

    ComfyUI Manager: search "GOAT Nodes", install, restart. Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/AconexOfficial/ComfyUI_GOAT_Nodes.git
    

    then restart ComfyUI. Nothing else needed - it's a single arithmetic operation.

    Common issues & troubleshooting

    Dividing by zero. Neither input has a documented default or minimum floor above zero, so if b ends up at 0 - an uninitialized upstream node, a miscalculated value - you're looking at a division-by-zero error. Worth a sanity check upstream (a Capped Int node, or a simple conditional) if b is coming from anywhere that could plausibly be zero.

    Expected a truncated (floor) result and got something one off. This node rounds to the nearest integer, not down - 7 / 2 gives you 4, not 3. If your use case actually wants floor division (always round down, the way most programming languages' integer division works by default), this isn't that node; you'd want a different math node configured for floor/truncate instead.

    Negative numbers. The node's own input range isn't restricted to positive values the way the Capped nodes are, so negative a or b should work, but rounding behavior at exact .5 boundaries with negative numbers is the kind of edge case worth testing once for your specific use case rather than assuming a particular convention.

    Category🐐 GOAT Nodes/Math

    Inputs (2)

    NameTypeDefaultDescription
    aINTβ€”
    bINTβ€”

    Outputs (1)

    NameTypeDescription
    INTINTβ€”