ComfyUI Node

Float Absolute Value

Strip the sign off a float in ComfyUI

By jamesWalker55·Created 3 years ago·Updated about a year ago· 215
Float Absolute Value
    • FLOAT
    value0.00

    JWFloatAbsolute takes one float and returns its absolute value - the magnitude, with any negative sign thrown away. -0.4 becomes 0.4, 0.7 stays 0.7. That's the entire node.

    Where this actually matters: any time you've computed a difference and you only care how big it is, not which direction it went. Subtract two values and you might get a negative; run the result through JWFloatAbsolute and you've got a clean magnitude you can feed into a threshold, a strength, or a comparison. It's the natural follow-up to JWFloatSub - difference first, then strip the sign. A lot of "how far apart are these two numbers" logic is exactly a subtract followed by an absolute.

    It also saves you from a whole class of quiet bugs. Plenty of downstream parameters - strengths, denoise values, dimensions - get weird or outright break when handed a negative. Dropping an absolute-value node in the path guarantees whatever comes out is zero or positive.

    What it actually does

    Unlike its two-input siblings, this one takes a single value. It outputs abs(value). The input value is FLOAT, defaults to 0, with the usual absurdly wide range (±1e17). Positive stays positive, negative flips positive, zero stays zero. No rounding, no clamping - just the magnitude.

    The inputs and outputs that matter

    One required input, one output - the simplest node in the whole pack:

    • value - the float to take the absolute value of (FLOAT). Note it's value, not a/b like the two-input math nodes.

    Output: a single FLOAT, always ≥ 0.

    How to install it

    Pack: jamesWalker55/comfyui-various. ComfyUI Manager - search Various ComfyUI Nodes by Type, install, restart. Or clone it:

    cd ComfyUI/custom_nodes
    git clone https://github.com/jamesWalker55/comfyui-various
    

    then restart. No dependencies at all. If cloning the full pack feels like overkill for one abs node - fair - the author designed it so you can just drop comfyui_primitive_ops.py (which holds every Float and Integer node) into custom_nodes/ and skip the rest.

    Common issues & troubleshooting

    It takes one input, not two. If you came here from the add/subtract/multiply nodes expecting a and b, this one only has value. Wire your number into that.

    It doesn't round or clamp. Absolute value only removes the sign - -3.7 becomes 3.7, not 4 and not 1. If you also need rounding you'll want a float-to-integer conversion; if you need a floor or ceiling, that's JWFloatMax / JWFloatMin. This node does exactly one thing, which is the point - and doing one thing well is really the whole ethos of this pack.

    CategoryjamesWalker55

    Inputs (1)

    NameTypeDefaultDescription
    valueFLOAT0.00-100000000000000000–100000000000000000

    Outputs (1)

    NameTypeDescription
    FLOATFLOAT