Nodes/More Math/Float -> Int
ComfyUI Node

Float -> Int

Because ComfyUI will not take a float where it wants an int

By mcDandy·Created about a year ago·Updated 3 days ago· 5
Float -> Int
    • INT
    value0.00

    This is the dumbest node in the pack and you will use it constantly. Float -> Int takes one float and hands back an int, and that's the whole job. It exists because ComfyUI's type system is strict about wires: plenty of inputs - seed, steps, width, height, batch size - are typed INT, and if a math node hands you a float, you can't plug it straight in. This one-liner converts so the graph doesn't refuse the connection.

    How it works

    The conversion is int(value), so it truncates toward zero. 2.0 becomes 2, 2.999 becomes 2, −2.9 becomes −2. It does not round. If you need proper rounding, round inside a float math node first (round(x) is in the expression language, since this comes from the More Math pack), then convert.

    Inputs and output

    • value - a FLOAT, default 0. That's the only input.
    • Output - an INT, ready for any int-typed socket downstream.

    That's the entire schema. There are no options, no mode switches, nothing to misconfigure. If you're converting in the other direction, grab Int -> Float from the same pack; if you want int -> bool, that one exists too. The pack author clearly got tired of shipping this family of conversions inline.

    Installing it

    It's part of More Math (mcDandy/more_math). ComfyUI Manager: search "More Math" and install. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/mcDandy/more_math
    cd more_math
    pip install -r requirements.txt
    

    Restart after. Dependencies are just antlr4-python3-runtime and torch - nothing heavy, nothing to download. The pack needs a current ComfyUI though, so if the nodes don't appear, update ComfyUI before debugging anything else.

    Any gotchas?

    Honestly, no. The only real trap is forgetting it truncates. Say you compute a width as 1024.7 from some formula and feed it straight in - you get 1024, not 1025. Round first if that matters to you. And don't expect fractional anything to survive: the moment something's an int in ComfyUI, it's an int all the way down.

    CategoryMore math

    Inputs (1)

    NameTypeDefaultDescription
    valueFLOAT0.00

    Outputs (1)

    NameTypeDescription
    INTINT