Nodes/Quality of life Suit:V2/Equation2params _O
ComfyUI Node

Equation2params _O

Two variables, two formulas, one node

By omar92·Created 3 years ago·Updated 5 months ago· 181
Equation2params _O
    • FLOAT
    • INT
    • FLOAT
    • INT
    x0.00
    y0.00
    equationx+y
    equation_2x+y

    Equation1param _O covers "one value, one formula." But the moment you're doing something like hi-res fix math - where the second-pass resolution depends on both a width and a height, or a batch size and a step count - you need two variables and often two outputs at once. That's exactly what Equation2params _O is: two inputs, two independent equations, and four outputs (a FLOAT and an INT for each result).

    It's the O/numbers-folder heavy of the Quality of Life Suit pack. Where its one-parameter sibling is the everyday calculator, this one is for the "I have two numbers and I want four derived numbers from them" situations - which, once you've done a few upscaling or batch workflows, you'll recognize as surprisingly common.

    How it works

    Same eval() machinery as the one-variable version, just doubled. Both x and y are substituted into each equation (as parenthesised values) before Python evaluates them. equation = "x+y" with x=2, y=3 gives 5; equation_2 = "x*y" gives 6. Standard Python operators and builtins work; the math module doesn't.

    Inputs:

    • x (FLOAT) - first variable, default 0, accepts wire input.
    • y (FLOAT) - second variable, default 0, accepts wire input.
    • equation (STRING, multiline) - required, default x+y. Can use both x and y.
    • equation_2 (STRING, multiline) - optional, default x+y. If you leave it empty, that pair just isn't computed.

    Outputs, in order:

    1. FLOAT - result of the first equation.
    2. INT - first result truncated to integer.
    3. FLOAT - result of the second equation.
    4. INT - second result truncated to integer.

    The int() truncation applies here too: 2.9 → 2, no rounding.

    Where it fits

    This is the node for coupled math. Want a batch layout where x is image count and y is grid width? equation = "x // y" gives rows, equation_2 = "x % y" gives leftovers. Doing hi-res fix sizing? Feed width and height, compute the target second-pass resolution and the denoise delta in one place. The optional second equation is the subtle win - you often want both a FLOAT for a slider and an INT for an index, or two related values (like a pair of upscale factors) computed from the same inputs.

    The caveats match its sibling: keep equations to valid Python, don't expect math.*, and an invalid expression will print equation is not valid to the console and return the string "NAN", which then breaks the INT conversion with an exception. It's a calculator - a good one, but a calculator.

    Installing it

    Part of the Quality of Life Suit pack (omar92/ComfyUI-QualityOfLifeSuit_Omar92). Install via ComfyUI Manager (search "Quality of Life Suit") or clone:

    cd <ComfyUI>/custom_nodes
    git clone https://github.com/omar92/ComfyUI-QualityOfLifeSuit_Omar92.git
    

    Restart ComfyUI properly. No models, no dependencies. The pack's config.json defaults autoUpdate to true; disable it if you don't want startup pulls.

    Common issues

    • "The second output pair is always 0." Check equation_2 - the default is x+y, but if you cleared it and expected it to compute anyway, it won't. Empty means "skip."
    • "Four outputs is overkill." You can ignore the INTs and use only the FLOATs, or vice versa - unused outputs are free.
    • "Same crash on bad input as the one-variable version." Yes. Validate before queueing; the "NAN" failure mode is inherited from the shared solveEquation helper.

    If you find yourself stacking two Equation1param _O nodes side by side, this is the node that collapses them into one clean block.

    CategoryO/numbers

    Inputs (4)

    NameTypeDefaultDescription
    xFLOAT0.000–18446744073709550000
    yFLOAT0.000–18446744073709550000
    equationSTRINGx+y
    equation_2optSTRINGx+y

    Outputs (4)

    NameTypeDescription
    FLOATFLOAT
    INTINT
    FLOATFLOAT
    INTINT