Number Transform
Eight one-number transforms in a single dropdown
- float_val
- int_val
Sometimes you need to do one thing to a number: round it, flip its sign, take its square root. Pulling in a full math node for that feels like overkill, which is why Number Transform exists - a single node with a dropdown of eight single-value operations, from floor to sin to negate. It's the "calculator" node of DebugPadawan's ComfyUI Essentials, a pure-Python utility pack. No models, no GPU, just math.* in a dropdown.
How it works
Two required inputs:
value- the number to operate on (FLOAT, default 0, step 0.001)operation- the dropdown, eight choices:floor,ceil,round,abs,sin,cos,sqrt,negate
Two outputs (always both):
float_val- the result as a FLOATint_val- the result as an INT (truncated)
The implementation is a straightforward dispatch: floor/ceil/round snap the value to a whole number, abs takes the absolute value, sin/cos compute the trig (expect radians, not degrees!), sqrt takes the square root, and negate flips the sign. One deliberate behavior: sqrt of a negative number returns 0.0 instead of erroring - Python's math.sqrt would raise, and the author chose to be forgiving.
Where you'll use it
- Resolution math.
floororrounda computed resolution so it's a clean multiple, then feed it to a latent/image size node that chokes on fractional dimensions. - Animation.
sin/cosof a frame counter gives you smooth oscillation for sweeping a parameter - a cheap easing curve without writing anything. - Direction flips.
negatereverses a value;absstrips sign. Both pair nicely withNumber Comparefor conditional branching. - Spot math mid-pipeline - instead of adding a whole math node, transform in place.
Installing it
Whole pack, one install. ComfyUI Manager, searching for "DebugPadawans-ComfyUI-Essentials," or:
cd ComfyUI/custom_nodes
git clone https://github.com/DebugPadawan/DebugPadawans-ComfyUI-Essentials
Then restart ComfyUI. The requirements (numpy, torch, opencv-python) are already satisfied by stock ComfyUI; no downloads, no models. And when you're searching Manager, don't confuse this with cubiq's "ComfyUI Essentials" - a different, larger pack in maintenance mode.
Gotchas
- Trig is in radians.
sin(90)is not1; it'ssin(90 radians). If you're thinking in degrees, convert first (aNumber Remapfrom degrees to radians isto_min=0, to_max=3.14159). int_valtruncates toward zero, it doesn't round -int(-2.7)is-2. If you wanted rounding, use theroundoperation and takefloat_val.sqrtof negative → 0.0 silently. Great for not crashing, but easy to misread as a bug if you expected an error.- It's a small, quiet pack; for a node this mechanical, the code is the documentation.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| value | FLOAT | 0.000 | — |
| operation | COMBO | 8 options: floor, ceil, round, abs, sin, cos, +2 |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| float_val | FLOAT | — |
| int_val | INT | — |