ComfyUI Node

Number → Int

The polite way to force any number into an integer

By danipisca07·Created 6 months ago·Updated 6 months ago· 0
Number → Int
    • INT
    value0

    If you've spent more than an afternoon in ComfyUI you've met the red wire: a node hands you a FLOAT and the next node demands an INT, and the graph refuses to connect them. That mismatch is the whole reason this node exists. SL_NumberToInt takes any numeric value - INT, FLOAT, or the looser NUMBER type - and hands you back a clean integer.

    Here's the thing about the NUMBER type, because it's the piece beginners usually don't have explained to them. ComfyUI's primitive types are strict: an INT wire will not plug into an INT-refusing input, and a FLOAT refuses to become an INT on its own. NUMBER is the escape hatch - an input typed NUMBER accepts both INT and FLOAT wires. Inside this pack, and in most packs that use it, a NUMBER is just a float wearing a friendlier label.

    So the pipeline is: something upstream gives you a value that could be either, you run it through this node, and out comes an INT you can trust. Seeds, step counts, width and height, batch sizes - the settings that insist on whole numbers - all accept this cleanly.

    Mechanically it's one line: int(value), which truncates toward zero. 3.9 becomes 3. -3.9 becomes -3. There is no rounding anywhere in this pack, and that catches people constantly. If you're converting a value like 2.999999 that should be 3, you'll get 2, because that's what truncation does. If you actually want rounding, round the value upstream before it hits this node.

    The inputs and outputs are as simple as they get:

    • value (NUMBER) - whatever numeric wire you have. INT or FLOAT both plug in.
    • Output: INT - the truncated result.

    Installing it

    This ships as part of ComfyUI-SimpleLogics by danipisca07, a lightweight utility pack. The easiest path is ComfyUI Manager: open Manager → Install Custom Nodes → search "SimpleLogics" → install, then restart ComfyUI. Or clone it manually:

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

    Then restart ComfyUI. There's no requirements.txt, no models to download, nothing to pip install - the whole pack is pure Python with zero dependencies, so this install is about as painless as custom nodes get. Find the node by right-clicking the canvas → Add Node → search "Number → Int" (it lives under the SimpleLogics/Convert menu group).

    Common gotchas

    • It truncates, it doesn't round. Repeatedly converting 0.999999 to INT in a loop gives you 0 every time, which is usually not what you meant. This is the #1 surprise with the whole SimpleLogics Convert family.
    • The default value is 0, so if you forget to wire it, you'll silently get 0 rather than an error. That's a quiet bug generator in a big graph - wire it or label it.
    • Use it on the receiving end of your chain, not early: only convert to INT right before the node that insists on INT, so you don't lose the decimal info the rest of the graph might still want.

    It's a boring node, and I mean that as a compliment. It does one tiny job and does it with no dependencies and no surprises beyond the truncation thing.

    CategorySimpleLogics/Convert

    Inputs (1)

    NameTypeDefaultDescription
    valueNUMBER0

    Outputs (1)

    NameTypeDescription
    INTINT