Nodes/ComfyMath/FloatBinaryOperation
ComfyUI Node

FloatBinaryOperation

An actual calculator inside your graph

By evanspearman·Created 3 years ago·Updated about a year ago· 192
FloatBinaryOperation
    • FLOAT
    op
    a0.000
    b0.000

    FloatBinaryOperation is the node people mean when they say "I need to do math in ComfyUI." Two float inputs, one dropdown to pick the operation, one float output. It's a calculator you drop into the graph instead of computing a value in your head and typing it in - which matters more than it sounds, because the moment either input is itself computed (an upscale factor, a ratio derived from an input image, a value another node produced at runtime) you can't just type it in. This node is how ComfyUI does arithmetic on values it doesn't know until the workflow actually runs.

    How it works

    You pick an operation from op - eleven of them: Add, Sub, Mul, Div, Mod, Pow, FloorDiv, Max, Min, Log, Atan2. Most are self-explanatory; Log is presumably a as the value with b as the base (or vice versa - the README doesn't spell out argument order for every operation, so if you're relying on Log or Atan2 specifically, sanity-check the result against a value you already know), and Atan2 is the two-argument arctangent, useful if you're doing anything with angles or vector direction. Feed a and b, get a single float back.

    The inputs and outputs that matter

    • op - the operation dropdown; this is the whole point of the node.
    • a, b - the two float operands (default 0, step 0.001 - fine-grained enough for CFG or denoise-scale math).
    • Output - a single FLOAT, ready to feed a sampler's CFG, a denoise value, an upscale factor, or another FloatBinaryOperation if you're chaining several together.

    Installing it

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

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

    then restart. No pip dependencies beyond ComfyUI's own, no model downloads - it's a small, self-contained Python pack, live the moment ComfyUI restarts.

    Common issues

    The most common mistake isn't with this node, it's with what people reach for instead of it: hardcoding a value that should've been computed. If you find yourself typing the same multiplication into three different widgets by hand across a workflow, that's the sign you want this node feeding all three instead - change the inputs once and everything downstream updates.

    Division deserves a specific callout: Div on a b of 0 will error your run rather than silently produce something like inf, so if b comes from another computed value (rather than a value you're setting by hand), it's worth guarding against zero somewhere upstream if there's any chance of it.

    On the pack overall: ComfyMath hasn't had active maintenance since roughly early 2024 by community reports - a user asking about a feature addition was told the author had moved on - but it's plain arithmetic with no external calls or model weight dependencies, so that inactivity hasn't translated into real-world breakage. It's about as low-risk a custom node as you'll install; the tradeoff is that if ComfyUI's frontend ever does break its socket typing in a way that affects it, don't expect a fast community fix.

    Categorymath/float

    Inputs (3)

    NameTypeDefaultDescription
    opCOMBO11 options: Add, Sub, Mul, Div, Mod, Pow, +5
    aFLOAT0.000
    bFLOAT0.000

    Outputs (1)

    NameTypeDescription
    FLOATFLOAT