ComfyUI Node

Integer Divide

Divide two integers (and get a float back)

By jamesWalker55·Created 3 years ago·Updated about a year ago· 217
Integer Divide
    • FLOAT
    a0
    b0

    Divides integer a by integer b. The one thing to know up front, because it surprises people: the output is a FLOAT, not an INT. Ten divided by four gives you 2.5, not 2. It's true division, so it keeps the decimal part.

    You'd use it to compute a ratio or a fraction inside the graph - split a total into parts, work out a scaling factor, turn a count into a proportion. Like the rest of this pack's math nodes, it exists so a number can be derived from other numbers at runtime instead of being typed in as a constant.

    How it works

    a / b, real division, returning a float. This is deliberate - if it truncated to an integer you'd lose information silently, so instead it hands you the exact quotient and lets you decide what to do with the fractional part.

    Inputs and outputs

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

    Output is a single FLOAT, the result of the division.

    Installing it

    Part of the pack's comfyui_primitive_ops file. Install via ComfyUI Manager (search Various ComfyUI Nodes by Type / comfyui-various) or clone:

    cd ComfyUI/custom_nodes
    git clone https://github.com/jamesWalker55/comfyui-various
    

    Restart ComfyUI. No models, no extra dependencies.

    Common issues

    Two things bite here, and both are worth internalizing.

    One: the output is a float. If whatever you're feeding wants an integer - a resolution, a frame count, a step count - 2.5 won't do. Run the result through JWFloatToInteger (in this same pack) to get back to a whole number, and know that it'll round or truncate, so plan for that. People wire this straight into an INT socket, get a type error or an unexpected value, and don't realize the node was never going to give them a clean integer.

    Two: dividing by zero. If b is 0, there's no valid answer and the node will error out and stop your run. If the denominator is coming from somewhere dynamic that could ever be zero, guard against it upstream rather than letting the whole workflow fall over.

    If you actually wanted integer (floor) division - the kind where 10 ÷ 4 = 2 - this isn't quite it; you'll get 2.5 and then have to convert. That mismatch between the node's name and its float output is the single most common confusion, so now you know.

    And the usual: if it loads red as missing in a shared workflow, install the pack via Manager's "Install Missing Custom Nodes" or clone the repo.

    CategoryjamesWalker55

    Inputs (2)

    NameTypeDefaultDescription
    aINT0-18446744073709550000–18446744073709550000
    bINT0-18446744073709550000–18446744073709550000

    Outputs (1)

    NameTypeDescription
    FLOATFLOAT