Nodes/zhangp365/ComfyUI-utils-nodes/Float Multiple and Add Literal
ComfyUI Node

Float Multiple and Add Literal

Float Multiple and Add Literal

By zhangp365·Created 2 years ago·Updated 5 months ago· 135
Float Multiple and Add Literal
    • x
    • ax + b
    • ax + b(int)
    number0.00
    a_aignpositive
    a1.000
    b1.000

    This is a linear equation in node form: ax + b. Not glamorous, but it's the kind of small math utility that saves you from chaining three separate multiply/add nodes together every time a workflow needs to rescale a value - turning a 0–1 strength slider into a 0–100 range, converting a normalized value into pixel units, or nudging a number by a fixed offset before it feeds into something else that expects a different scale.

    Inputs: number is your x - the required input value, ranging 0 to 1,000,000. a (default 1, step 0.001) is your multiplier, and b (default 1, step 0.001) is your additive offset - together they compute a * x + b. a_aign (a typo in the schema for what's presumably meant to be "sign," worth knowing so it doesn't confuse you when you see it in the node UI) is an enum - positive or negative, defaulting to positive - that controls whether a gets applied as-is or negated, letting you flip between ax + b and -ax + b without retyping a negative value into a itself.

    Outputs: three of them. x just passes your original input straight through - handy if you need both the raw value and the transformed one available downstream without a separate reroute. ax + b is the float result of the actual computation. ax + b(int) is the same result cast to an integer, for whenever whatever you're feeding it into - a step count, a frame number, anything that specifically wants an INT rather than a FLOAT - won't accept a decimal value.

    Install: search "ComfyUI-utils-nodes" in ComfyUI Manager, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/zhangp365/ComfyUI-utils-nodes
    

    Restart ComfyUI afterward. Zero dependencies beyond the base pack - this is arithmetic, nothing more.

    Where this actually catches you:

    • The a_aign sign toggle is easy to miss entirely, since the default positive setting means everything behaves exactly like a normal ax + b and you'd never notice the field exists until you need to flip a coefficient's sign - worth remembering it's there the next time you need -ax + b instead of retyping a as a negative number (which, given a's range starts effectively unconstrained downward per its step value, might not even be the more natural way to express it depending on how your graph reads).
    • The ax + b(int) output truncates or rounds (the schema doesn't specify which) rather than guaranteeing you get exactly the integer you'd expect from manual rounding - if the exact rounding behavior matters for your use case, sanity-check a known input/output pair once rather than assuming standard rounding.
    • number's range floors at 0, not into negative territory - if you need a genuinely negative starting x, this node's input range won't let you type it in directly; you'd need to restructure your equation (adjust a's sign and b's offset instead) to get an equivalent negative-input result out of a non-negative x.
    Categoryutils/numbers

    Inputs (4)

    NameTypeDefaultDescription
    numberFLOAT0.000–1000000
    a_aignoptCOMBOpositive2 options: positive, negative
    aoptFLOAT1.000
    boptFLOAT1.000

    Outputs (3)

    NameTypeDescription
    xFLOAT
    ax + bFLOAT
    ax + b(int)INT