ComfyUI Node

Number Round

Stop tripping over floating point noise

By DebugPadawan·Created about a year ago·Updated 5 months ago· 2
Number Round
    • rounded
    • rounded_string
    value0.00
    decimal_places2

    Floats lie. Do enough math in a workflow and you'll eventually get a 0.30000000000000004 where a sane 0.3 should be, or a denoise value that prints as 0.7499999999 and makes your logs look broken. Number Round cleans that up: it rounds a value to a chosen number of decimal places and hands you both the number and a pretty string version. If your workflow generates filenames, labels, or anything a human reads, this is the node that keeps it tidy.

    It ships in DebugPadawan's ComfyUI Essentials, a small pure-Python utility pack. No models, no GPU - this is round() plus a format string.

    How it works

    Two required inputs:

    • value - the float to round (default 0)
    • decimal_places - 0 to 10, how many digits after the point (default 2)

    Two outputs:

    • rounded - the number as a FLOAT
    • rounded_string - the same value formatted as a STRING, always showing exactly decimal_places digits

    The string output is the sneaky-good part. rounded as a float still carries binary floating-point baggage; rounded_string uses f"{value:.2f}"-style formatting, so you get clean text like "3.14" instead of "3.1400000000000001". That's the output to feed into a Text Joiner or a filename builder.

    Where you'll use it

    • Filenames and labels. Save nodes and metadata builders want clean strings; round your CFG, strength, or seed-derived values before formatting.
    • Debug output. A clean 0.75 beats a 0.75000000001 in any log or Debug Print.
    • Int-adjacent work. Set decimal_places to 0 to collapse a float to a whole number (as a float) before converting.

    Installing it

    One install gets the whole pack. ComfyUI Manager, searching for "DebugPadawans-ComfyUI-Essentials," or:

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

    Then restart ComfyUI. Its requirements (numpy, torch, opencv-python) are already in stock ComfyUI; nothing to download, no models. Just don't get it mixed up with cubiq's "ComfyUI Essentials" - different pack, in maintenance mode, and easy to click by accident in Manager's search results.

    Gotchas

    • Python's round() uses banker's rounding. round(2.5) gives 2, not 3, because Python rounds half-to-even. If you're doing financial-style rounding or anything where "up" matters at exactly .5, this node (like Python itself) will surprise you. The rounded_string uses the same underlying rounding.
    • The two outputs agree, but aren't interchangeable. rounded is a float for math; rounded_string is text for humans and filenames. Wire accordingly.
    • It's a tiny, quiet node from a small pack - no model downloads, no community drama, just round and ship.
    CategoryDebugPadawan/Number

    Inputs (2)

    NameTypeDefaultDescription
    valueFLOAT0.00
    decimal_placesINT20–10

    Outputs (2)

    NameTypeDescription
    roundedFLOAT
    rounded_stringSTRING