ComfyUI Node Runs on cloud

Absolute value

Strip the sign off a computed number

By Derfuu·Created 3 years ago·Updated 2 years ago· 455
Absolute value
    • FLOAT
    Value1.00
    negative_out

    This is abs() as a node. You give it a number, it hands back the magnitude with the sign thrown away - -3.5 becomes 3.5. That's it, and if you've never needed it you can happily ignore it. Where it earns a spot is inside those dimension-math chains Derfuu's pack exists for: you subtract one size from another, the result might come out negative depending on which is bigger, and something downstream (a crop offset, a padding amount, a width) refuses to take a negative. Absolute value is the little clean-up node that guarantees a positive.

    How it works

    It computes the absolute value of the incoming float. Nothing exotic - the only wrinkle is a toggle that lets you flip the result negative instead, for the rarer case where you specifically need the value to point the other way.

    The inputs and outputs that matter

    Two inputs, one output:

    • Value (FLOAT, default 1, steps of 0.01) - the number to strip the sign from. In practice you're feeding this from another node, not typing it.
    • negative_out (toggle, default off) - leave it off for normal absolute value. Flip it on and the node returns the negative magnitude instead (so 3.5 and -3.5 both come out as -3.5). Think of it as "force the sign" rather than a second feature.
    • Output: FLOAT - the magnitude, wired onward into whatever needed a guaranteed-positive number.

    How it fits a workflow

    The classic use: you're computing the difference between two dimensions to place something. Divide, Multiply, and the size-getter nodes can all produce a value whose sign depends on input order, and Absolute value normalizes that so the offset is always a distance rather than a direction. Pair it with Ceil or Floor when the consumer wants an int.

    How to install it

    Via ComfyUI Manager: search the pack name (Derfuu_ComfyUI_ModdedNodes), install, restart. Or by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Derfuu/Derfuu_ComfyUI_ModdedNodes
    

    and restart. Pure Python, no dependencies to install, no models to download.

    Common issues & troubleshooting

    It's outputting negatives and you didn't expect it. Check negative_out - if it's on, that's the whole job of the node, and it'll force every result negative.

    You wanted an integer. This outputs FLOAT. If the next node wants an INT (image width, offset in pixels), run the result through Ceil, Floor, or Derfuu's Integer node to convert.

    The node is missing/red in a downloaded workflow. Derfuu has form for deleting deprecated nodes on pack updates rather than keeping them around labeled as old, so an ancient graph can reference a name that no longer exists - reconnect a current copy. And a ModuleNotFoundError mentioning Derfuu_ComfyUI_ModdedNodes_legacy means you've got a duplicate folder; keep just one, named Derfuu_ComfyUI_ModdedNodes. For a brand-new graph, note that ComfyUI's ecosystem has plenty of math nodes now, so you may not need Derfuu at all unless a workflow you inherited already leans on it.

    CategoryDerfuu_Nodes/Functions/Converters

    Inputs (2)

    NameTypeDefaultDescription
    ValueFLOAT1.00
    negative_outCOMBO2 options: false, true

    Outputs (1)

    NameTypeDescription
    FLOATFLOAT