Invert Sign
Flip your numbers' sign, conditionally or not
- inv_float
- inv_int
Sometimes you need a negative of a number, and there is no node for it, so you reach for a float math node and wire it backwards. InvertSign is the thing you were actually looking for: it takes an int and/or a float and flips the sign - either always, or only when the value is positive, or only when it's negative. It's a tiny node with a genuinely useful third mode most people don't notice at first.
Why you'd reach for it
In a real workflow the use cases are the kind you discover after the tenth "how do I do this again" graph surgery: reversing a denoise amount, negating a strength value so two branches pull in opposite directions, or converting a signed offset into its mirror for a paired generation. The two output wires - one float, one int - mean you can drive two consumers with one node without a conversion step in between.
How it works
The mode enum is the whole brain. always_invert negates whatever you feed it. invert_if_positive leaves negatives alone and flips positives. invert_if_negative is the mirror image. Under the hood it's a two-line lambda dispatch, so there's no clever math to trip on: -val if condition(val) else val.
One detail worth knowing: both numeric inputs are optional and both default to zero, and both outputs are always produced. Feed only in_float and the int output still comes out - as the negated (or not) value of the default zero, so inv_int will be 0 rather than absent. That's fine for most graphs, but if you're comparing outputs downstream, remember that zero is a real answer.
Inputs and outputs
- mode (enum) -
always_invert,invert_if_positive,invert_if_negative. This is the only required input, and it's the one you'll actually set. - in_float (FLOAT, optional) - the floating-point value to transform.
- in_int (INT, optional) - the integer value to transform.
- inv_float / inv_int - the transformed results. Wire whichever your downstream needs.
That's the complete interface. Three modes, two optional inputs, two outputs.
Installing it
It comes with the comfyui-lopi999-nodes pack:
cd ComfyUI/custom_nodes
git clone https://github.com/LaVie024/comfyui-lopi999-nodes
Restart ComfyUI after cloning, or find "comfyui-lopi999-nodes" in the ComfyUI Manager installer. No models to download, no dependencies beyond the pack itself.
Common issues
The subtle one is the conditional modes plus zero. Zero is neither positive nor negative, so invert_if_positive and invert_if_negative both leave it untouched - which is almost always what you want, but worth knowing if you're building a graph where zero is a meaningful "off" state. And if a value doesn't seem to be inverting, check which wire you're reading: in_float feeds inv_float and in_int feeds inv_int, and they don't cross-pollinate.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| mode | COMBO | 3 options: always_invert, invert_if_positive, invert_if_negative | |
| in_floatopt | FLOAT | — | |
| in_intopt | INT | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| inv_float | FLOAT | — |
| inv_int | INT | — |