Nodes/More Math/Float math
ComfyUI Node

Float math

One node to retire your float spaghetti

By mcDandy·Created about a year ago·Updated 4 days ago· 5
Float math
  • V
  • FloatFunc
  • stack
  • FLOAT
  • STACK
remember_stackfalse

If you've ever built a workflow where a single value has to be clamped, remapped, and eased before it reaches the sampler, you know the pain: a snake of "Math Expression", "Clamp", and "Remap" nodes that takes half the canvas just to compute one number. Float math is the node from the More Math pack that collapses all of that into one expression box. It's the pack's on-ramp, and honestly the one you'll reach for every day.

It's not a dictionary of one-off operations. You type an expression, the node evaluates it with the inputs you've wired in, and out comes a float. The default is a*(1-w)+b*w - that's a lerp between a and b by w, which tells you right away what the author (Daniel Martinek, building under the handle mcDandy) had in mind: replacing the classic "Lerp" node. But the expression language is the point, and it's deep.

How it works

More Math ships a real parser (ANTLR4, which is why antlr4-python3-runtime is in its requirements) plus a huge function library. Inside Float math you get the basics - +, -, *, /, ^, abs, sqrt, ln, exp - and then it gets genuinely useful: clamp(x, min, max), lerp(a, b, t), smoothstep(x, e0, e1), smootherstep, remap(v, i_min, i_max, o_min, o_max), easing functions like sine_ease and elastic_ease, and even gamma. You can define custom functions and variables with varname = expression; and chain statements. It's a little scripting language, not a single formula.

The inputs that matter

The node uses autogrow inputs, which is the newer More Math style: V is a list of float inputs (V0, V1, ... up to 50) and F is a second list (F0, F1, ...). In an expression you reference them directly - clamp(V0 * 1.5, 0, 1) - or mix in F0 as a blend weight. The FloatFunc field is the expression itself. remember_stack and the optional stack input are the pack's state mechanism, which you can ignore until you need to carry a value between nodes or across batch iterations.

Outputs are FLOAT (the result) and STACK. Wire the float anywhere a float goes: CFG scale, denoise, LoRA strength, sampler seed scaling.

Installing it

Same story for every node in this pack - there's nothing special about Float math:

cd ComfyUI/custom_nodes
git clone https://github.com/mcDandy/more_math
cd more_math
pip install -r requirements.txt

Then restart ComfyUI. Or use ComfyUI Manager and search for "More math" - it's the pack title. The only real dependency is antlr4-python3-runtime plus torch, which you already have. No model files, no downloads. One caveat worth knowing: this pack is very new and moving fast, so the function list and node internals can shift between updates. Update it and old workflows can error on a renamed function.

Gotchas

The expression language is its own thing, so a typo fails hard with a parse error rather than a gentle hint - the field autocompletes if you use the built-in editor, which helps. And if a workflow you download uses variables you don't recognize, that's likely More Math's per-type variables leaking in (like X/Y on image nodes); on a float node you mostly live in V0..Vn, F0..Fn, and the plain math functions. When you're starting, keep one expression per node instead of chaining a thousand statements in a single field - it debugs far better.

CategoryMore math

Inputs (4)

NameTypeDefaultDescription
VCOMFY_AUTOGROW_V3
FloatFuncSTRING,SYNTAX_TREEV0Expression to use on inputs
remember_stackBOOLEANfalseIf enabled, stack is copied at output leading to changes being remembered during batch operations (node runs multiple times in sucession). If disabled each batch gets it's own copy of the stack.
stackoptSTACKAccess stack between nodes

Outputs (2)

NameTypeDescription
FLOATFLOAT
STACKSTACK