ComfyUI Node

abs

Strip the sign off any number

By StableLlama·Created about a year ago·Updated 4 days ago· 48
abs
  • value
  • FLOAT

When the sign is the problem, not the number

Absolute value is the "how big is it, ignoring direction" operation. Negative CFG drift, a negative difference between two values, an offset that can point either way - if all you care about is magnitude, this node makes it positive. abs(-4.2)4.2, abs(4.2)4.2. That's the whole job.

It's the entry point of the pack's math section (Basic/maths in the node browser), and honestly the simplest node StableLlama ships. There's no trap, no configuration, one number in, one number out.

How it works

The node runs abs(float(value)). A detail worth noticing: the value input renders as a text field even though it's a number type. That's so you can type an exact decimal (like -0.8333333) without fighting a spinner widget - but it's still just a plain number, not a formula. float() will happily parse -4.2 or 1e3, and it will not evaluate 3+2. If you find yourself wanting to type expressions, the pack's separate "formula" node is the one with real math-parsing powers; this one wants a number.

Because the input accepts both FLOAT and INT, and the output always comes out as a FLOAT, you may want to run the result through the pack's float→int cast node if a downstream node insists on integers. Rounding is on you - abs doesn't round.

Inputs and outputs

  • value (FLOAT or INT, default 0) - the number to strip the sign from. Accepts either type.

Output is a single FLOAT: the magnitude, always non-negative.

Installing it

Ships in Basic data handling by StableLlama, the r/StableDiffusion regular whose model writeups (his Flux Klein 9B conclusions thread, the RealVisXL comparisons) are better known than his code. The pack is deliberately dependency-free - zero runtime requirements in its pyproject, no models, no API keys - so it installs cleanly everywhere.

Via ComfyUI Manager, search "Basic data handling"; or:

cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling

Restart ComfyUI and look under Basic/maths.

Troubleshooting

There's almost nothing to break here. The two things worth remembering: the output is always a FLOAT (cast it if you need an INT), and the text input won't accept expressions - if you type -2+5 you'll get an error because that's not a valid number literal. Type the number, let the pack's formula node do the arithmetic.

CategoryBasic/maths

Inputs (1)

NameTypeDefaultDescription
valueFLOAT,INT0

Outputs (1)

NameTypeDescription
FLOATFLOAT