Float Math
Two numbers in, a result out, zero ceremony
- float_result
- int_result
Core ComfyUI is weirdly shy about basic arithmetic. You want to compute a strength as "1 minus the existing strength," or scale a width by 0.75, and there's no obvious node for it. Float Math is that node: two floats in, pick an operation, get the result - and it hands you both a float and an int version, so you rarely have to add a conversion step after it.
It's part of DebugPadawan's ComfyUI Essentials, a small MIT-licensed utility pack that fills exactly these boring gaps in the graph. No generation, no models - just glue that keeps your numbers flowing.
How it works
Under the hood it shares a calculation helper with the pack's Integer Math node. The operation set here is add, subtract, multiply, divide, power, max, min. One notable absence: no modulo - that's on the integer variant, not this one. If you need remainder math, use Integer Math instead.
The mechanism is worth one careful look because of what it doesn't do: division by zero doesn't error. The code guards it and returns 0.0. Same story for anything that would blow up - you get a zero, not a crash. That's convenient for robustness and a trap if you don't notice the math silently went to zero.
Inputs and outputs that matter
- a, b - the two operands, FLOAT inputs with 0.01 step on the widget.
- operation - the dropdown: add / subtract / multiply / divide / power / max / min.
Outputs are float_result (the real result) and int_result - which is int() of the float, meaning it truncates toward zero. 2.9 becomes 2, not 3. If you wanted rounding, this isn't it; that's what a Float to Int node with a round mode is for.
Install
Standard custom-node fare:
cd ComfyUI/custom_nodes
git clone https://github.com/DebugPadawan/DebugPadawans-ComfyUI-Essentials.git
Restart ComfyUI, or install via ComfyUI Manager by searching "DebugPadawan". requirements.txt lists numpy, torch, and opencv-python - numpy and torch already ship with ComfyUI and the shipped code never imports cv2, so no heavy downloads, no model files, no API keys.
Where people get burned
- The silent divide-by-zero. If your denominator can ever be zero (and in a graph it always can), you'll get
0.0with no error to tell you. Clamp your divisors first. int_resulttruncates. For anything like CFG or strength math where rounding matters, grab the float and convert explicitly.- No modulo here. People reach for this node expecting the full arithmetic kit; modulo lives on the integer version.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| a | FLOAT | 0.00 | — |
| b | FLOAT | 0.00 | — |
| operation | COMBO | 7 options: add, subtract, multiply, divide, power, max, +1 |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| float_result | FLOAT | — |
| int_result | INT | — |