ComfyUI Node

Number Transform

Eight one-number transforms in a single dropdown

By DebugPadawan·Created about a year ago·Updated 5 months ago· 2
Number Transform
    • float_val
    • int_val
    value0.000
    operation

    Sometimes you need to do one thing to a number: round it, flip its sign, take its square root. Pulling in a full math node for that feels like overkill, which is why Number Transform exists - a single node with a dropdown of eight single-value operations, from floor to sin to negate. It's the "calculator" node of DebugPadawan's ComfyUI Essentials, a pure-Python utility pack. No models, no GPU, just math.* in a dropdown.

    How it works

    Two required inputs:

    • value - the number to operate on (FLOAT, default 0, step 0.001)
    • operation - the dropdown, eight choices: floor, ceil, round, abs, sin, cos, sqrt, negate

    Two outputs (always both):

    • float_val - the result as a FLOAT
    • int_val - the result as an INT (truncated)

    The implementation is a straightforward dispatch: floor/ceil/round snap the value to a whole number, abs takes the absolute value, sin/cos compute the trig (expect radians, not degrees!), sqrt takes the square root, and negate flips the sign. One deliberate behavior: sqrt of a negative number returns 0.0 instead of erroring - Python's math.sqrt would raise, and the author chose to be forgiving.

    Where you'll use it

    • Resolution math. floor or round a computed resolution so it's a clean multiple, then feed it to a latent/image size node that chokes on fractional dimensions.
    • Animation. sin/cos of a frame counter gives you smooth oscillation for sweeping a parameter - a cheap easing curve without writing anything.
    • Direction flips. negate reverses a value; abs strips sign. Both pair nicely with Number Compare for conditional branching.
    • Spot math mid-pipeline - instead of adding a whole math node, transform in place.

    Installing it

    Whole pack, one install. ComfyUI Manager, searching for "DebugPadawans-ComfyUI-Essentials," or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/DebugPadawan/DebugPadawans-ComfyUI-Essentials
    

    Then restart ComfyUI. The requirements (numpy, torch, opencv-python) are already satisfied by stock ComfyUI; no downloads, no models. And when you're searching Manager, don't confuse this with cubiq's "ComfyUI Essentials" - a different, larger pack in maintenance mode.

    Gotchas

    • Trig is in radians. sin(90) is not 1; it's sin(90 radians). If you're thinking in degrees, convert first (a Number Remap from degrees to radians is to_min=0, to_max=3.14159).
    • int_val truncates toward zero, it doesn't round - int(-2.7) is -2. If you wanted rounding, use the round operation and take float_val.
    • sqrt of negative → 0.0 silently. Great for not crashing, but easy to misread as a bug if you expected an error.
    • It's a small, quiet pack; for a node this mechanical, the code is the documentation.
    CategoryDebugPadawan/Math

    Inputs (2)

    NameTypeDefaultDescription
    valueFLOAT0.000
    operationCOMBO8 options: floor, ceil, round, abs, sin, cos, +2

    Outputs (2)

    NameTypeDescription
    float_valFLOAT
    int_valINT