Evaluate Floats JK๐
Evaluate Floats JK turns math into INT, FLOAT and STRING
- INT
- FLOAT
- STRING
ComfyUI's native math is... sparse. You get a handful of binary math nodes and then it's back to wiring two nodes per operation. Evaluate Floats JK fixes the common case with a single expression: write ((a + b) - c) / 2 once, feed it three float variables, and you get the result out as INT, FLOAT, and STRING simultaneously. That triple output is the whole trick - you can drive a KSampler's step count (INT) and a filename (STRING) from the same calculation without a conversion node in between.
The engine is SimpleEval, the same sandboxed evaluator used by the whole Evaluate family. Your expression runs with a, b, c bound to the three float inputs, and the whitelist covers arithmetic, bitwise ops, comparisons, abs, min, max, and friends. It's safe by design - no arbitrary code execution, just expression math.
The inputs that matter:
python_expression- required, the only thing you really edit. Default((a + b) - c) / 2is a fine template.a,b,c- optional float variables, default 0, with a fine 0.0001 step. Wire real numbers into at least one or your expression just evaluates to whatever the defaults produce.
Where people get burned: the INT output is a hard int() cast, so 3.7 becomes 3, not a rounded 4. If you need rounding, write it into the expression (round(...) is available in the whitelist). Second: because all three variables default to 0, an expression like a / b blows up the moment you forget to connect b - division by zero is an error here, and it propagates as a clear "Error evaluating expression" ValueError. Check your connections before you blame the node.
Install. Part of ComfyUI-JakeUpgrade:
cd ComfyUI/custom_nodes
git clone https://github.com/jakechai/ComfyUI-JakeUpgrade
cd ComfyUI-JakeUpgrade
pip install -r requirements.txt
Or ComfyUI Manager โ "JakeUpgrade". Windows portable: install.bat or ../../../python_embeded/python.exe -s -m pip install -r requirements.txt. Restart. The simpleeval dependency is in the pack's requirements - it's tiny, no model downloads.
Gotchas: remember the INT-vs-FLOAT truncation trap above, and keep in mind that everything in the expression must resolve to a number - SimpleEval won't quietly coerce a string. If a shared JakeUpgrade workflow reports missing nodes, set LOAD_DEPRECATED_NODES = True in config.ini; and the README says to disable ComfyUI MultiGPU on current ComfyUI to dodge CUDA errors.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| python_expression | STRING | ((a + b) - c) / 2 | Python expression using variables a, b, c (e.g., 'a + b * c') |
| aopt | FLOAT | 0.0000 | Float variable a for expression |
| bopt | FLOAT | 0.0000 | Float variable b for expression |
| copt | FLOAT | 0.0000 | Float variable c for expression |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| INT | INT | โ |
| FLOAT | FLOAT | โ |
| STRING | STRING | โ |