Nodes/ComfyMath/NumberToInt
ComfyUI Node

NumberToInt

Cast ComfyMath's generic number to a real INT

By evanspearman·Created 3 years ago·Updated about a year ago· 192
NumberToInt
    • INT
    a0

    The counterpart to CM_NumberToFloat: you've done some math using ComfyMath's own generic NUMBER type, and now you need a plain INT to feed a seed field, a batch size, a frame count, or anything else in ComfyUI that specifically wants an integer socket. NumberToInt does that single conversion.

    It's a small utility node in ComfyMath, evanspearman's math/logic pack, and exists for the same reason its float sibling does: ComfyUI's type system won't let a NUMBER output connect to an INT input directly, even though they're both just numbers underneath. You need an explicit cast node to bridge them.

    How it works

    Feed a (NUMBER) in, and the node outputs it as INT. No operator to pick, no options - it's a pure type conversion.

    The one thing worth keeping in mind: if the NUMBER value flowing in isn't already a whole number, going to INT means it has to become one somehow, and the schema doesn't spell out whether that's a round or a truncate. If you're feeding this a value that could have a fractional part and the exact integer matters (a frame count, a seed), drop a preview/text node on the output while you're building the workflow and confirm what actually comes out before you trust it in a batch run.

    This kind of conversion shows up in real graphs doing genuinely mundane but necessary work - a shared LTX-2 video workflow used ComfyMath's float/int conversion nodes specifically to get a framerate value into the integer shape a downstream node expected, rather than anything more elaborate.

    Inputs and outputs

    • a (NUMBER, default 0) - the generic-typed value to convert.
    • Output: INT - the value as a concrete integer socket.

    How to install it

    Via ComfyUI Manager: search ComfyMath, install, restart. By hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/evanspearman/ComfyMath.git
    

    then restart ComfyUI. No dependencies, no models - it's arithmetic in plain Python, nothing else to set up.

    Common issues & troubleshooting

    The integer you get isn't what you expected from a fractional input. As above - verify with a preview node rather than assuming round vs. truncate behavior, especially if the value feeds something sensitive like a seed.

    A downstream node still refuses the connection. Confirm it actually wants INT - if it wants FLOAT, you want CM_NumberToFloat instead.

    You're getting a NUMBER value and don't know why. It's almost always because it came out of one of ComfyMath's own Number* nodes, which all operate on the generic NUMBER type by design - you need a cast like this one to hand the result off to the rest of your graph.

    Missing node error on workflow load. Install ComfyMath via Manager as described above, then reload.

    The pack looks stale. A 2024 community thread confirmed the author had stepped back from active development. That's a non-issue for a plain type cast like this one - nothing here depends on anything that can go out of date.

    Categorymath/conversion

    Inputs (1)

    NameTypeDefaultDescription
    aNUMBER0

    Outputs (1)

    NameTypeDescription
    INTINT