ComfyUI Node

divide

Divide that rounds down — and refuses to divide by zero

By StableLlama·Created about a year ago·Updated 4 days ago· 48
divide
    • INT
    int11
    int21

    Division is where integer math in ComfyUI starts lying to you, and this node is the one that does the honest thing: it floors. divide from the Basic data handling pack takes two integers and returns the integer division - Python's //, not the / you learned in school. 5 / 2 is 2.5; 5 // 2 is 2. The node is up-front about that, and it's the single most important thing to understand before you use it.

    What it does

    int1 // int2, full stop. Integer division truncates toward negative infinity - -5 // 2 is -3, not -2 - which is a Python quirk that will surprise you exactly once. And it has one hard rule: if int2 is 0, it raises a ValueError rather than returning anything. That's the strict version of the pack's division pair; if you need a zero divisor to mean something, the divide (zero safe) sibling is the one that returns an "infinity" value instead of crashing.

    Inputs and outputs

    • int1 - INT, default 1. The dividend.
    • int2 - INT, default 1. The divisor.
    • Output INT - the floored quotient.

    No rounding mode, no "remainder" output - if you need the leftover, pair it with the pack's modulus node, which returns int1 % int2. The two are designed to work together: quotient plus remainder covers every case you'd get from a math textbook.

    Install

    From the Basic data handling pack. ComfyUI Manager → search "Basic data handling" → install → restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
    

    then restart ComfyUI. Pure Python, no dependencies, no models.

    Where people get burned

    The 5 / 2 = 2 surprise is the big one - if you're computing an upscale factor or a tile count and the result looks one short, this is why. It's integer division, not real division, so for anything where a fraction matters (aspect ratios, scale factors, intermediate math), reach for the pack's float divide instead. And remember the zero rule: it won't silently give you garbage, it will throw. If your divisor can legitimately be zero in a workflow, you want divide (zero safe) or a guard node upstream.

    CategoryBasic/INT

    Inputs (2)

    NameTypeDefaultDescription
    int1INT1
    int2INT1

    Outputs (1)

    NameTypeDescription
    INTINT