Math Constants | Basic
Pi, e, tau, and the two constants everyone forgets are constants
- FLOAT
MathConstants ("Math Constants | Basic") is a dropdown that hands you a famous number, and honestly, it's the node you'll use once and then keep around for the two options that aren't famous at all. Pick a constant from five choices - pi, e, tau, inf, nan - and get a FLOAT out.
The mechanism is unglamorous: it's Python's math module values, passed through. pi is 3.14159..., e is Euler's number, tau is 2π (the one some people argue should be the real circle constant). But the interesting pair is inf (infinity) and nan (not-a-number) - those are the two that show up when your math goes sideways, and this node is a legitimate way to inject them deliberately.
The inputs that matter
- constant - the one and only input. Dropdown:
pi,e,tau,inf,nan.
The output FLOAT wires into anything that takes a number.
Why you'd reach for it
Honest takes, in order of usefulness:
nanis the debugging superpower. Feed it into a math node and every value downstream becomesnan- instantly tracing which path a bad value travels through your graph. It's the graph version of a probe.inffor sentinel values. Sometimes you want a number larger than anything real so aminoperation ignores it, or smaller than anything so amaxignores it. Infinity is perfect for that.pi/taufor anything circular - rotation math, seamless-tile work, animated angle sweeps. You'll typically fold it into aBasicMathnode with a multiplication.e- the one you'll probably never use, but it's there if you're doing exponential scheduling.
Installing it
Same install as every node in this pack - pure Python, no dependencies, no models:
cd ComfyUI/custom_nodes
git clone https://github.com/akatz-ai/ComfyUI-Basic-Math
Restart ComfyUI, find it under Basic Math ➕ → Constants. Or use ComfyUI Manager → Install Custom Nodes → search "ComfyUI-Basic-Math".
The gotchas
The big one: nan doesn't compare equal to anything, including itself. If you're checking "is this result nan?" with a NumberComparison and ==, it will never match - that's IEEE 754 behavior, not a bug in the node. And inf and nan are floats, so they'll flow through as FLOAT. Also, remember the menu shows "Math Constants | Basic" - the | Basic suffix is the pack's naming convention. If you find yourself reaching for pi in multiple workflows, this node saves you typing 3.14159 into a widget and hoping you remembered enough digits.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| constant | COMBO | 5 options: pi, e, tau, inf, nan |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| FLOAT | FLOAT | — |