Nodes/zsq_prompt/Float Math Operation
ComfyUI Node

Float Math Operation

Fractional Math for Your Graph, When Integers Won't Cut It

By windfancy·Created 2 years ago·Updated 5 months ago· 2
Float Math Operation
    • result
    • value1
    • value2
    value10.000
    value20.000
    operationadd

    ComfyUI's sliders deal in floats constantly - CFG, denoise, controlnet strength - so at some point you need to do math that isn't whole numbers. FloatMathOperation is the decimal version of the pack's IntMathOperation: two floats in, one result out, operands passed through. If you've ever wanted to compute "half the denoise value" or "1.5× that CFG" and reached for a calculator, this is the node that plugs the arithmetic straight into your graph.

    What it does

    Pick an operation and it runs when the graph executes:

    • add, subtract, multiply, divide - the standard four. Division by zero returns 0 rather than erroring, so a bad input won't kill the queue.
    • max, min - pick the larger or smaller value.
    • random - a random float between value1 and value2, which is a neat way to inject controlled randomness into a workflow (say, jitter a CFG slightly per run).

    Unlike the integer sibling, there's no modulus - remainders don't make much sense on decimals, and the pack's IntMathOperation covers that need anyway.

    The inputs and outputs that matter

    Inputs are value1, value2, and operation - both values are FLOAT widgets that also accept wired connections, so you can chain them from other nodes. Outputs are result plus value1 and value2 passed through, so a single calculation can branch to several consumers without extra nodes. That passthrough is the same trick the int version uses, and it's why these nodes compose into little arithmetic sections instead of dead-ends.

    Where you'll actually use it

    The float version earns its keep in scheduling and conditioning work: derive a denoise from a step count, scale a controlnet strength by a factor, clamp a CFG with min/max before it hits a sampler that hates extremes. It pairs naturally with the pack's image nodes - take a width from imageSize, multiply by 0.75, feed the result into a resize - and with ConnectionString when a numeric value has to become part of a prompt or filename.

    Installing it

    Part of windfancy/zsq_prompt - search "zsq_prompt" in ComfyUI Manager and install, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/windfancy/zsq_prompt
    

    then restart. Heavy dependencies install alongside (transformers, onnx, ultralytics) that this node never touches. And the Manager "conflict" flag you may see on zsq_prompt is the pack's generic class names colliding in the manager's index - the community's advice is to ignore it unless you're actually running the other pack it names.

    Verdict

    The float half of a two-node arithmetic set. Unspectacular, exactly as useful as you need it to be, and the random mode is a sleeper feature for anyone who likes per-run variety.

    CategoryZSQ/utils

    Inputs (3)

    NameTypeDefaultDescription
    value1FLOAT0.000-18446744073709550000–18446744073709550000
    value2FLOAT0.000-18446744073709550000–18446744073709550000
    operationCOMBOadd7 options: add, subtract, multiply, divide, max, min, +1

    Outputs (3)

    NameTypeDescription
    resultFLOAT
    value1FLOAT
    value2FLOAT