ComfyUI Node

Switch Float

Flip between two values on a condition

By danipisca07·Created 6 months ago·Updated 6 months ago· 0
Switch Float
    • FLOAT
    conditionfalse
    if_true0.00
    if_false0.00

    Switch Float is the float-specialist version of the pack's Switch Any. Give it a boolean condition and two floats - if_true and if_false - and it hands back one of them depending on the condition. Nothing gets converted, nothing gets truncated; you just pick a value at runtime. It's the node you reach for when a single checkbox or comparison should decide between two numerical settings.

    Why you'd reach for it

    The classic use is swapping a float parameter between two presets without rebuilding the graph. A checkbox decides whether you're in "fast preview" or "final render" mode, and that one boolean routes between two denoise strengths, two CFG values, or two upscale factors. Or a Compare node upstream decides "image is small enough" and the switch picks between two scale amounts. One boolean, two values, one output - that's the whole pattern, and it's everywhere once you look for it.

    It also composes with the pack's logic and compare nodes: Compare Float or Number → Bool produces the condition, Switch Float does the routing. Compared to the untyped Switch Any, the payoff here is strict FLOAT sockets - ComfyUI will refuse to connect an INT (or auto-convert in a way you didn't ask for), which catches a whole class of wiring mistakes before they become silent bugs.

    How it works

    A single Python conditional: if_true if condition else if_false. No clamping, no defaults being secretly applied - when the condition is false, you get exactly if_false; when true, exactly if_true. The author's description is "Returns if_true when condition is True, otherwise returns if_false. Works with floats." It lives in SimpleLogics/Switch, and the pack ships identical siblings for ints and strings (and a wildcard Switch Any for everything else).

    The inputs that matter

    Three required inputs:

    • condition - the BOOLEAN that picks the branch (defaults to False)
    • if_true - the FLOAT returned when condition is true (default 0)
    • if_false - the FLOAT returned when condition is false (default 0)

    One FLOAT output, ready for any float socket.

    Installing it

    Comes with danipisca07/ComfyUI-SimpleLogics, the dependency-free pure-Python pack - no requirements.txt, no models. Install from ComfyUI Manager (search "SimpleLogics") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/danipisca07/ComfyUI-SimpleLogics
    

    Restart ComfyUI and you're done.

    Common issues

    The main gotcha is expecting the switch to do something with the values - it doesn't, it just selects. If you're feeding it a computed value and wondering why the output isn't clamped or rounded, that's a different node's job. The other common confusion: if both your values are integers, an INT input will try to auto-convert into the float socket, and the result can be subtly off - use Switch Int for integer work instead. Otherwise this is about as failure-proof as nodes get. (And the usual pack note: installing it also registers an undocumented GeoCalib camera node - ignore that one.)

    CategorySimpleLogics/Switch

    Inputs (3)

    NameTypeDefaultDescription
    conditionBOOLEANfalse
    if_trueFLOAT0.00
    if_falseFLOAT0.00

    Outputs (1)

    NameTypeDescription
    FLOATFLOAT