Float Multiple and Add Literal
Float Multiple and Add Literal
- x
- ax + b
- ax + b(int)
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_aignsign toggle is easy to miss entirely, since the defaultpositivesetting means everything behaves exactly like a normalax + band 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 + binstead of retypingaas a negative number (which, givena'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 startingx, this node's input range won't let you type it in directly; you'd need to restructure your equation (adjusta's sign andb's offset instead) to get an equivalent negative-input result out of a non-negativex.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| number | FLOAT | 0.000–1000000 | — |
| a_aignopt | COMBO | positive | 2 options: positive, negative |
| aopt | FLOAT | 1.000 | — |
| bopt | FLOAT | 1.000 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| x | FLOAT | — |
| ax + b | FLOAT | — |
| ax + b(int) | INT | — |