Unary Math | Basic
Unary Math for Seeds, Schedules, and Sine Waves
- value
- NUMBER
Unary Math is the single-number sibling of the Basic Math | Basic node: you give it one value and an operation, it gives you one number back. The other node pairs two numbers (a + b, a / b, min/max and friends); this one takes a lone value and pushes it through one of twelve built-in operations - abs, neg, sqrt, sin, cos, tan, log, log10, exp, floor, ceil, round. Think of it as a one-slot Swiss Army knife for the numbers sloshing around your graph.
Why bother? Because in ComfyUI, numbers arrive with baggage. Seeds are ugly ints, denoise values are floats you want to bump by a bit, and if you're doing anything with time or frames - animation, LoRA strength ramps, alternating noise - you end up wanting sin to oscillate or floor to snap a value to integer steps. This node is where that math lives without you writing a single line of Python. It's the same family of "why doesn't the core workflow have this" tooling as the rest of the Basic Math pack, and it's dead simple to reach for mid-workflow.
How it works
It's a thin wrapper over Python's math module. You pick an operation, it runs math.sin(value), math.abs(value), whatever you chose, and returns the result. But the wrapper makes two judgment calls you should know about, because they're quiet:
sqrt,log, andlog10take the absolute value of your input.sqrt(-4)doesn't error and doesn't give you NaN - it gives you2.0.log(-5)gives you the log of 5. The node never tells you your sign was wrong; it just silently flips it.log(0)andlog10(0)return negative infinity. Python would raise aValueError; this node catches that and returns-inf. Feed it a zero and your downstream widgets will suddenly be full of-infand you'll have to hunt the source.- Any other error returns
float('nan')- quietly, not as a red error bubble.
There's also a subtle type rule. Feed it an int and pick abs or neg and you get an int back; every other operation returns a float, no matter what went in. That matters if you're feeding the output into something that cares about the type, like an integer seed socket.
The inputs that matter
- value - a number,
INTorFLOAT, default 0.0. That's it for inputs. - operation - the dropdown with the twelve choices. Everything else is implied.
- NUMBER - the output, typed
INT,FLOAT, so it drops into most numeric sockets directly.
One honest caveat: round here uses Python's banker's rounding, where round(2.5) is 2, not 3. If you're rounding for display or scheduling and care about half-values going up, round will surprise you.
Installing it
Same pack as the rest of "Basic Math ➕": install via ComfyUI Manager (search ComfyUI-Basic-Math), or clone it:
cd ComfyUI/custom_nodes
git clone https://github.com/akatz-ai/ComfyUI-Basic-Math
# then restart ComfyUI
There are no model files and no dependencies beyond Python's standard library - the requirements.txt simply doesn't exist. It's a zero-friction install in an ecosystem where that's rarer than it should be.
Where people get burned
The biggest gotchas are the two silent behaviors above. A negative value into sqrt won't warn you, and a zero into log hands you -inf and moves on. If you're wiring Unary Math into a KSampler or a seed and suddenly see NaN or infinity in the output, check the sign and the zero before you blame the sampler. And remember the float-vs-int rule: if you need an integer seed out, keep it on abs/neg - or pipe it through round/floor/ceil and let the node hand you a float back. For a nine-line utility, it carries more footguns than you'd expect - but for an animated sine-wave oscillation or a quick abs on a noisy strength value, it's the node I grab.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| value | INT,FLOAT | 0 | — |
| operation | COMBO | 12 options: abs, neg, sqrt, sin, cos, tan, +6 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| NUMBER | INT,FLOAT | — |