ComfyUI Node

is round to x

A string-based equals check for people allergic to BOOL wires

By YMC-GitHub·Created 3 years ago·Updated about a year ago· 20
is round to x
    • boolean
    ◄text1►
    ◄isRoundTo1►

    Somewhere in the ymc suite there's a philosophy: numbers should travel as strings, because strings are what survive round-trips through prompt builders and text fields. Is round to x is that philosophy made visible - it takes two text inputs and outputs whether one rounds to the other, as a "True"/"False" string. It's a comparison node that never asks you to touch a BOOL socket.

    Where does that get you? Text-driven conditionals. If your seed, your batch counter, or some prompt-extracted value lives as a string, this gives you a gate without a cast: compare text against isRoundTo, and pipe the resulting boolean-string into the string-switch variant (switch a and b (isRoundTo)) to pick between two prompts. It's niche, but it's the missing connective tissue between "everything is text" and "I need to branch."

    How it works

    The comparison is deliberately fuzzy: both values are converted with int(round(float(value))) and then compared for equality. So "0.8" with isRoundTo = "1" returns True (0.8 rounds to 1), and "0.4" against "1" returns False. That "rounds to" behavior is why it's not a plain equals node - it's asking whether text lands in the rounding bucket of isRoundTo, which is exactly the question you'd want for a noisy numeric source like a weighted score or a scaled value.

    One implementation wrinkle: the inputs are named text and isRoundTo on the surface, and the output is a single STRING named boolean carrying "True" or "False".

    Inputs and outputs

    • text - the value under test, default "1"
    • isRoundTo - the target value, default "1"
    • Output: boolean - a STRING, "True" or "False" (note: a string, not a BOOL, so don't wire it into a node that demands a real boolean)

    Installing it

    # ComfyUI Manager: search "ymc suite" and install ymc-node-suite-comfyui
    # or:
    cd ComfyUI/custom_nodes
    git clone https://github.com/YMC-GitHub/ymc-node-suite-comfyui
    

    Restart after installing. Four tiny pure-Python PyPI helpers self-install; no models, no GPU cost.

    Gotchas

    • The output is text, not a real boolean. Feed it to switch a and b (isRoundTo), which does the same rounding comparison internally, or to something that accepts a "True" string - don't assume an implicit cast.
    • Because it rounds, "1.4" vs "1" is False while "1.5" vs "1" is True (Python rounds half to even, so 1.5 → 2). If you wanted strict equality, this is the wrong tool.
    • It's in ymc suite/text/plain, next to to number - if you find yourself casting to number just to compare, this node is the shortcut that skips the cast.
    Categoryymc suite/text/plain

    Inputs (2)

    NameTypeDefaultDescription
    textSTRING1—
    isRoundToSTRING1—

    Outputs (1)

    NameTypeDescription
    booleanSTRING—