ComfyUI Node

Divide

Divide — one box for division, with a zero-division guard built in

By aesethtics·Created about a year ago·Updated about a year ago· 1
Divide
    • int_result
    • float_result
    float_a1.00
    float_b1.00
    int_a1
    int_b1

    Division is where hand-rolled ComfyUI math usually breaks, because division by zero is the one operation that crashes a workflow instead of just returning a weird number. This node from the Utilitools pack does plain division - with a guard so dividing by zero hands you (0, 0.0) instead of an error splattered across your console. That's its whole personality, and honestly it's the reason you'd pick it over wiring up a calculation yourself.

    Like the pack's other math nodes, it has two float inputs and two int inputs, all optional. float_a, float_b, int_a, int_b all default to 1, and the formula is: (float_a * int_a) / (float_b * int_b). The float inputs get multiplied by their int counterparts first, then divided. So you can mix types freely - a float on top and an int on the bottom works exactly the way you'd hope.

    The mechanism, and the guard

    The multiplication-then-division is the subtle bit worth understanding. float_a and int_a are treated as both numerators (they multiply together), and float_b and int_b as both denominators. You can't, say, divide float_a by int_a separately - the two int inputs don't divide each other, they both feed the bottom. It's a design choice that keeps the node to four inputs, and in practice you'll almost always use it as a simple two-value divide: numerator in one input, denominator in another, defaults filling the rest.

    Both outputs are always produced: int_result and float_result. Division rarely lands on a whole number, so int_result truncates - 7 / 2 gives 3 as an int and 3.5 as a float. Grab the float output for anything precision matters on.

    The zero-division guard: if the computed divisor is 0, you get (0, 0.0) back rather than an exception. It's silent, which is the tradeoff - you won't get a crash, but you also won't get told anything went wrong. If your denominator can legitimately be zero and you need to notice, this node will quietly paper over it.

    Where it fits

    Typical uses: computing an aspect ratio from width and height (width / height - though the pack's dedicated Aspect Ratio node does that with a nicety), working out a scale factor between two resolutions, or deriving a per-frame value for animation work. It's glue math, and it's the division box the pack expects you to reach for when you need it.

    Installing it

    Same as every node in this pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/aesethtics/ComfyUI-Utilitools
    

    or search "Utilitools" in ComfyUI Manager, then restart. It's under Utilitools → Math. No requirements.txt, no downloads, no dependencies beyond Python's standard library. A zero-community pack, a zero-friction install, and a node that doesn't crash on zero - which is more than some tools can claim.

    CategoryUtilitools/Math

    Inputs (4)

    NameTypeDefaultDescription
    float_aoptFLOAT1.00
    float_boptFLOAT1.00
    int_aoptINT1
    int_boptINT1

    Outputs (2)

    NameTypeDescription
    int_resultINT
    float_resultFLOAT