Nodes/ComfyUI Text Processor/Simple Expression Floats
ComfyUI Node

Simple Expression Floats

Fractional math without the node spaghetti

By rookiestar28·Created 10 months ago·Updated 10 days ago· 16
Simple Expression Floats
    • INT
    • FLOAT
    • STRING
    python_expression((a + b) - c) / 2
    print_to_console
    a0.00
    b0.00
    c0.00

    Simple Eval Floats is the decimal-precision sibling of the pack's integer evaluator. Where the INT version truncates, this one keeps the decimals - which is what you want for the entire category of ComfyUI math that involves ratios, weights, CFG tweaks, or denoise fractions.

    Think of the cases: a sampler step that should be steps * 1.5, a denoise value derived from a * 0.7, a strength that's b + 0.1 because you're nudging a slider. ComfyUI's stock math nodes make you assemble these from primitives; this node is one text box. The default expression even shows the idea - ((a + b) - c) / 2 - three inputs, one formula, done.

    How it works

    Same engine as its siblings: simpleeval, a sandboxed Python-expression evaluator that ships with the pack. You get real expressions over the three float inputs a, b, c - arithmetic, comparisons, round(), min(), max() - without any of the footguns of arbitrary code execution. print_to_console echoes the result to the terminal when you want to see it.

    The three outputs are the same triple-cast as the INT version, which is exactly what makes these nodes useful:

    • FLOAT - the actual result, precision intact
    • INT - truncated integer form
    • STRING - string form for text nodes and dynamic labels

    So a single node can drive a numeric input and produce the text for a filename or caption from the same value. The string output is easy to overlook and genuinely handy.

    One note on inputs: the float inputs have step: 0.01, so the widget lets you dial 1.5 or 2.25 directly. Wire them to other nodes' outputs if you want the math to react to the workflow.

    Install

    Comes with ComfyUI Text Processor:

    cd ComfyUI/custom_nodes
    git clone https://github.com/rookiestar28/ComfyUI_Text_Processor.git
    pip install -r requirements.txt
    

    Restart, or install via ComfyUI Manager by searching "ComfyUI Text Processor". simpleeval installs as a dependency.

    Gotchas

    Float results can carry binary floating-point noise - 0.1 + 0.2 in the STRING output may show 0.30000000000000004. If you're building labels from the string, wrap the expression in round(..., 2) to keep things readable. And as with all the eval nodes, it's the Python subset simpleeval knows - no lambdas, no comprehensions, no imports. If you need something genuinely exotic, that's what the Python Expression node is for; for everything else, this is the unglamorous workhorse.

    CategoryComfyUI Text Processor/Logic

    Inputs (5)

    NameTypeDefaultDescription
    python_expressionSTRING((a + b) - c) / 2Numeric expression evaluated with floating-point variables a, b, and c.
    print_to_consoleCOMBOPrint variables, expression, and result to the server console.
    aoptFLOAT0.00Floating-point value bound to variable a.
    boptFLOAT0.00Floating-point value bound to variable b.
    coptFLOAT0.00Floating-point value bound to variable c.

    Outputs (3)

    NameTypeDescription
    INTINTInteger-cast result.
    FLOATFLOATFloat result.
    STRINGSTRINGString representation of the result.