Nodes/ComfyUI-JakeUpgrade/Evaluate Floats JK๐Ÿ‰
ComfyUI Node

Evaluate Floats JK๐Ÿ‰

Evaluate Floats JK turns math into INT, FLOAT and STRING

By jakechaiยทCreated 2 years agoยทUpdated 3 months agoยท 147
Evaluate Floats JK๐Ÿ‰
    • INT
    • FLOAT
    • STRING
    โ—„python_expression((a + b) - c) / 2โ–บ
    โ—„a0.0000โ–บ
    โ—„b0.0000โ–บ
    โ—„c0.0000โ–บ

    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) / 2 is 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.

    Category๐Ÿ‰ JK/โœ–๏ธ Math

    Inputs (4)

    NameTypeDefaultDescription
    python_expressionSTRING((a + b) - c) / 2Python expression using variables a, b, c (e.g., 'a + b * c')
    aoptFLOAT0.0000Float variable a for expression
    boptFLOAT0.0000Float variable b for expression
    coptFLOAT0.0000Float variable c for expression

    Outputs (3)

    NameTypeDescription
    INTINTโ€”
    FLOATFLOATโ€”
    STRINGSTRINGโ€”