Nodes/ComfyMath/NumberBinaryOperation
ComfyUI Node

NumberBinaryOperation

One arithmetic node for both ints and floats

By evanspearman·Created 3 years ago·Updated about a year ago· 192
NumberBinaryOperation
    • NUMBER
    op
    a0
    b0

    NumberBinaryOperation is the same eleven operations as FloatBinaryOperation - Add, Sub, Mul, Div, Mod, Pow, FloorDiv, Max, Min, Log, Atan2 - but it operates on ComfyMath's own generic NUMBER type instead of a plain FLOAT. The point of NUMBER is that it can hold either an integer or a decimal, so this one node covers both without ComfyMath needing separate int and float versions of every arithmetic operation. If you're building a longer calculation chain out of ComfyMath's NUMBER-family nodes - this one alongside NumberUnaryOperation - this is the workhorse that does the actual math.

    How it works

    Pick an operation from op, feed two NUMBER values into a and b, get one NUMBER back. Functionally it behaves exactly like FloatBinaryOperation; the difference is entirely in what socket type it speaks.

    The inputs and outputs that matter

    • op - the operation dropdown.
    • a, b - the two NUMBER operands (default 0).
    • Output - NUMBER, which chains into other ComfyMath NUMBER nodes, not directly into a plain FLOAT or INT socket elsewhere.

    Installing it

    ComfyUI Manager: search ComfyMath, install, restart. Manually:

    cd ComfyUI/custom_nodes && git clone https://github.com/evanspearman/ComfyMath
    

    then restart. No pip dependencies beyond ComfyUI's own, no models to fetch.

    Common issues

    The honest advice here: unless you specifically need to mix integer and float values through the same calculation chain, most people are better off using FloatBinaryOperation or IntBinaryOperation directly - they speak ComfyUI's native FLOAT/INT sockets, which means their output plugs straight into almost anything else in your graph. NUMBER only connects to other ComfyMath NUMBER sockets, so choosing this node commits you to converting in with FloatToNumber/IntToNumber and converting back out again afterward, which is extra wiring for no benefit if your whole calculation is one type anyway.

    Where it earns its keep: a chain where you genuinely start from a mix - an integer seed and a float multiplier, say - and want to keep doing math without converting at every single step. NUMBER absorbs that mixing so you only convert at the boundaries, once in and once out.

    Given how little this specific node gets used compared to its Float/Int siblings, it's the least battle-tested corner of an already small, quiet pack. ComfyMath has had no active maintainer since around early 2024 by community accounts, and this is arithmetic with no external dependencies, so the practical risk is low - but if something behaves unexpectedly here, check your wiring (a stray FLOAT trying to reach a NUMBER socket, or vice versa) before assuming it's a bug in the operation itself.

    Categorymath/number

    Inputs (3)

    NameTypeDefaultDescription
    opCOMBO11 options: Add, Sub, Mul, Div, Mod, Pow, +5
    aNUMBER0
    bNUMBER0

    Outputs (1)

    NameTypeDescription
    NUMBERNUMBER