🐳数学运算
A pocket calculator that lives inside your graph — with receipts
- result
- formula
ComfyUI workflows are 70% plumbing - nodes that hold numbers, pick values, and bend wires so the graph stays readable. MathOperations is that layer. You need a resolution that's a multiple of 8, a step count that's half of something else, a batch size derived from another value: instead of typing the answer in twice and praying you remember to update both, you wire a couple of ints in and let the graph compute it. It's from the 🐳 Pond Nodes pack (comfy_Pond_Nodes), under 🐳Pond/Tools.
The one thing that makes it worth reaching for over ComfyUI's built-in math: the formula output. It hands back the actual equation as a string, so you can see what was computed and how, which beats staring at a bare number when a value comes out wrong.
The inputs and outputs
Three numeric inputs:
- a and b - required integers, each from −999,999 to 999,999.
- c - optional third operand; leave it alone and most operations just ignore it.
The operation dropdown has 16 entries: add, subtract, multiply, divide, power, modulo, min, max, average, distance, log, exp, sin, cos, tan, atan2. Outputs are result (INT) and formula (STRING). Wire result anywhere a number is needed - a KSampler's steps, a Latent's dimensions, a filename counter.
The traps to know about
This node is integer-only, and it doesn't hide it well. Division rounds to the nearest integer - 5 ÷ 2 gives you 3, not 2.5. Power rounds too. If your math needs fractional precision, this isn't the node; reach for a float-capable utility. And division by zero doesn't crash - you get a 0 result and the formula string says Division by zero!, which is graceful but easy to miss if you're not reading the output. For a beginner, the practical version of this: use it for counts, resolutions, and step values (all integers anyway), and check the formula output the first time you set something up to make sure the operation did what you think.
Installing it
Every node in this pack installs identically. ComfyUI Manager → search comfy_Pond_Nodes → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Pondowner857/comfy_Pond_Nodes
cd comfy_Pond_Nodes
pip install -r requirements.txt
Then restart. MathOperations itself is pure Python standard library - it needs nothing from the pack's heavy requirements.txt (ultralytics, realesrgan, mediapipe and the rest are for the image nodes). If you only grabbed this pack for the tools, you can skip the full dependency install. The README does flag a known console-spam conflict with comfyui_HiDream-Sampler if you have that installed - worth knowing before you blame the wrong plugin.
The take
It's a workhorse, not a showpiece, and that's fine. Where it beats a calculator is iteration: change the inputs upstream and every consumer updates. Where it loses is precision - no floats, so keep it to integer-domain math and you'll never be surprised.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| a | INT | 0-999999–999999 | — |
| b | INT | 0-999999–999999 | — |
| operation | COMBO | add | 16 options: add, subtract, multiply, divide, power, modulo, +10 |
| copt | INT | 0-999999–999999 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| result | INT | — |
| formula | STRING | — |