Nodes/ComfyUI-SimpleLogics/Bool → Number
ComfyUI Node

Bool → Number

The same 0/1 trick, in float flavor

By danipisca07·Created 6 months ago·Updated 6 months ago· 0
Bool → Number
    • NUMBER
    valuefalse

    SL_BoolToNumber is SL_BoolToInt's slightly more flexible sibling. Same idea - a condition becomes a number - but instead of a strict integer you get a NUMBER output that's float-backed: True1.0, False0.0.

    The mechanism is one line: 1.0 if value else 0.0. And because it outputs the generic NUMBER type rather than INT, it plugs into both float-typed and NUMBER-typed inputs downstream. That's the practical difference between the two nodes: Bool → Int feeds integer ports, Bool → Number feeds float and NUMBER ports. If your target is a strength slider, a denoise value, a weight, or any continuous parameter, this is the one you want - multiplying a float by 0/1 works cleanly without any int-to-float widening worries.

    Where it earns its keep, same as its sibling but for continuous values:

    • Gating a strength: multiply a CFG or denoise value by condition ? 1.0 : 0.0 so a false condition zeroes it out inside the math chain.
    • Feeding NUMBER-typed ports: some custom nodes declare inputs as NUMBER, and this output connects there without a second cast.
    • Blending factors: scale a mix percentage by whether a feature is active.

    Inputs and outputs:

    • value (BOOLEAN) - the condition, default False
    • Output: NUMBER - 1.0 if true, 0.0 if false

    Installing it

    Part of ComfyUI-SimpleLogics - Manager: search "SimpleLogics" in Install Custom Nodes, install, restart. Manual:

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

    Restart and find it via Add Node → search "Bool → Number" (menu group SimpleLogics/Convert). No dependencies, no models to download.

    Choosing between the two

    This is the one decision the pack asks of you: Int or Number? Quick rule - if the thing you're feeding is a discrete parameter (seed, steps, batch size), use SL_BoolToInt. If it's a continuous one (strength, denoise, weight, opacity), use SL_BoolToNumber. When in doubt, the Number version is more forgiving because NUMBER connects to more ports; the only thing it can't do is feed an INT input directly.

    There's no trap here beyond the usual one: an unwired condition defaults to False, so you get 0.0 silently. Wire it, label it, and this becomes one of those nodes you stop noticing because it just works.

    CategorySimpleLogics/Convert

    Inputs (1)

    NameTypeDefaultDescription
    valueBOOLEANfalse

    Outputs (1)

    NameTypeDescription
    NUMBERNUMBER