𝙆 abc Math
A real expression calculator for your graph
- a
- b
- c
- INT
- FLOAT
Most math nodes in ComfyUI give you one operator and two inputs - an add node, a multiply node, pick your poison. abc Math skips that entirely: you type an actual expression using variables a, b, and c, and it evaluates it. Addition, subtraction, multiplication, division, power, modulo, plus built-in functions like min, max, round, sum, len - it's a real (if small) expression parser sitting inside a node, not a dropdown of fixed operations.
The one thing to get right immediately: the value field is a text box, not a number. You type the formula there - something like a * b + round(c) - and wire your actual numbers into the a, b, c slots. Beginners coming from other math nodes sometimes expect value to be a numeric input and end up confused when nothing computes; it's the formula, the numbers go elsewhere.
How it works
a, b, and c are wildcard-typed and optional, defaulting to 0 if left unwired. The README is explicit that they accept either plain numbers or "array shapes" - meaning you can wire in something like an image or latent tensor and use its shape in your expression, not just a bare float. That's a genuinely useful trick: instead of chaining an Image Size Extractor and then a separate math node, you can sometimes get away with feeding the tensor straight into a and referencing its dimensions in the expression. The node also automatically handles NaN results so a bad expression doesn't propagate garbage silently through the rest of your graph as a crash-inducing value.
The inputs and outputs that matter
- value (STRING) - the expression itself, using
a,b,cand the supported operators/functions. - a / b / c (optional, any type, default 0) - the variables your expression references.
- INT and FLOAT (both outputs, simultaneously) - the same result in both an integer and floating-point form, so you don't need a separate
To Intconversion afterward if that's the type you need.
Installing it
Comes with the full KayTool pack: ComfyUI Manager → search KayTool → install → restart, or cd ComfyUI/custom_nodes && git clone https://github.com/kk8bit/KayTool and restart. No extra dependency beyond the base pack requirements - this is pure Python expression evaluation, no model, no API call.
Common issues
The most common failure is a plain typo or unsupported syntax in the value field - since it's a custom parser, not full Python, functions or operators outside its documented set (the arithmetic operators plus min/max/round/sum/len and friends) won't work even if they're valid Python elsewhere. If your expression silently produces 0 or NaN-cleaned-to-0 instead of erroring, double-check you're not accidentally using a variable (a, b, c) that isn't wired to anything and is quietly defaulting to 0. And remember the dual output: if downstream expects a clean integer (a seed, a batch count) wire the INT output, not FLOAT - an unrounded float landing in an integer-only field elsewhere in your graph is a classic source of a cryptic type error a few nodes later.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| value | STRING | — | |
| aopt | * | 0 | — |
| bopt | * | 0 | — |
| copt | * | 0 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| INT | INT | — |
| FLOAT | FLOAT | — |