easy simpleMathDual
Evaluate two math expressions, get ints and floats out
- a
- b
- c
- d
- int1
- float1
- int2
- float2
Sometimes you need a number computed on the fly - half the width, the resolution times 1.5 for a hires pass, a step count derived from something else - and you don't want to hardcode it. easy simpleMathDual lets you type a math expression as text and spits out the result. The "Dual" part: it evaluates two expressions at once, which is exactly what you want for width/height pairs.
It's a small workhorse in automated or looping graphs. Wire a couple of upstream values in, write the formula, and the dimensions (or whatever) recompute themselves every run instead of you nudging sliders.
How it works
You give it two expression strings. It evaluates each and returns both an integer and a float version of the answer, so you can plug the result straight into whatever downstream input wants - INT for pixel dimensions and step counts, FLOAT for strengths and ratios. The optional inputs a, b, c, d are variables you can reference inside the expressions, so the math can depend on values coming from elsewhere in the graph.
The inputs and outputs that matter
value1/value2- the two expressions, as strings. Plain arithmetic like1024*1.5or, using the variable inputs,a/2.a,b,c,d(optional, any type) - feed numbers in here and reference them by letter in your expressions. This is what turns it from a calculator into a live formula node.- Outputs:
int1+float1(fromvalue1) andint2+float2(fromvalue2). Take whichever type the target input expects.
How to install it
ComfyUI Manager: search ComfyUI-Easy-Use, install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/yolain/ComfyUI-Easy-Use
then install.bat / pip install -r requirements.txt, restart. No models.
Common issues & troubleshooting
Int vs. float bites you. 1024/3 is 341.33…. The float output carries the real value; the int output is rounded/truncated. If you feed the int of a division into a pixel dimension expecting a multiple of 8, you may get an off number that a latent op rejects. Do the rounding in the expression, or take the float and let the downstream node coerce it.
Undefined variable. If your expression references c but you never connected input c, evaluation fails. Only use the letters you've actually wired.
It's for simple math, not a scripting engine. The name is honest - arithmetic on a few inputs. Don't expect it to be a full expression language with functions and conditionals for every case; for anything gnarlier, compute it upstream or use the pack's other logic nodes.
Feeding non-numbers in. The variable inputs are wildcard-typed, but the math only makes sense on numbers. Passing an image or string into a and referencing it will error.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| value1 | STRING | — | |
| value2 | STRING | — | |
| aopt | * | — | |
| bopt | * | — | |
| copt | * | — | |
| dopt | * | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| int1 | INT | — |
| float1 | FLOAT | — |
| int2 | INT | — |
| float2 | FLOAT | — |