Nodes/ComfyMath/FloatUnaryOperation
ComfyUI Node

FloatUnaryOperation

A scientific calculator for one float

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

    Every so often you need to do actual math inside a ComfyUI graph - take the square root of something, negate a value before it hits a scale input, exponentiate a decay curve - and reaching for a full Python-eval node feels like overkill for one operation. FloatUnaryOperation is the lighter answer: pick a math function from a dropdown, feed it one float, get the result back as a float. It's part of ComfyMath, evanspearman's small math-and-logic utility pack, and this node is the float arithmetic workhorse in it.

    How it works

    You choose an op - there are 32 of them - and supply a, your float. The node applies that single operation to a and outputs the result. The visible slice of the list covers the basics you'd expect: Neg, Inc, Dec, Abs, Sqr, Cube, Sqrt, Exp, Ln, Log10, Log2, Sin, and then about twenty more rounding out the rest of what a basic scientific calculator does. If you've ever wished ComfyUI had a "sqrt this value" node without writing custom code, this is that node - you're just picking the function instead of typing it.

    This is a straight function call, not a workflow feature - there's no batching, no list handling, no randomization. One float in, the same operation applied, one float out.

    Inputs and outputs

    • op - which operation to apply (32 choices, from simple sign-flips and increments up through roots, logs, and trig functions).
    • a (FLOAT, default 0, step 0.001) - the value being operated on.
    • Output: FLOAT - the result, ready to feed into anything else that takes a float widget or socket.

    How to install it

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

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

    and restart. No requirements.txt, no model downloads, no extra dependencies to fight with - it's pure Python math, so it's about as low-risk an install as a custom node gets.

    Common issues & troubleshooting

    You get NaN or infinity out and don't know why. A few operations here have restricted domains - square roots of negative numbers, logs of zero or negative numbers, and so on. Standard math libraries don't throw an error for that, they just hand back NaN or an infinity, and it silently propagates downstream until it surfaces somewhere confusing. If a value further down the graph looks wrong, trace it back and check whether one of these operations got fed a value outside its domain. ComfyMath's own FloatUnaryCondition node (IsNaN / IsFinite) is the quickest way to check that directly rather than guessing.

    The node "does nothing" visually. Like the rest of ComfyMath, this doesn't preview anything on its own - you'll want a preview/text node downstream (or one of the pack's own condition nodes) if you want to actually see the number it produced while you're debugging a graph.

    Reload after installing. As with any custom node pack, ComfyUI needs a full restart after git clone - a browser refresh alone won't pick it up.

    It's a small, largely finished pack. ComfyMath hasn't had much active development recently, and a 2024 community thread noted the original author had stepped back from the project. That's not really a concern for a pure-math node like this one - there's no model, no API, no external dependency to go stale - but don't expect new operations to get added; what's in the dropdown today is what you get.

    Categorymath/float

    Inputs (2)

    NameTypeDefaultDescription
    opCOMBO32 options: Neg, Inc, Dec, Abs, Sqr, Cube, +26
    aFLOAT0.000

    Outputs (1)

    NameTypeDescription
    FLOATFLOAT