Nodes/ComfyUI-JakeUpgrade/Float To Int JK๐Ÿ‰
ComfyUI Node

Float To Int JK๐Ÿ‰

The tiniest node that saves real headaches

By jakechaiยทCreated 2 years agoยทUpdated 3 months agoยท 146
Float To Int JK๐Ÿ‰
    • INT
    โ—„a0.00โ–บ

    If you've ever wired a computed value into an input that insists on an integer and gotten the red "wrong type" wire, this is the node for you. Float To Int JK takes one float and hands you back an integer. That's the whole job, and it's the kind of boring utility that keeps a graph from dying on a type mismatch five nodes downstream.

    How it works

    Under the hood it's one line: Python's int(a). The important behavior to internalize is that this truncates toward zero - it does not round. 3.7 becomes 3, 2.1 becomes 2, and -2.7 becomes -2. If you're used to round(), this will surprise you exactly once, usually when a resize dimension comes out one pixel short of where you wanted it.

    Inputs and outputs

    • a - the FLOAT you want to convert. That's the only input.
    • INT - the result, ready to plug into any integer slot: latent width/height, steps, seeds, batch counts.

    The classic use is cleaning up the output of float math. Say a resolution node hands you 1024.0 * 0.75 = 768.0 - technically an integer value but still typed as FLOAT. ComfyUI is strict about wire types, so you'd normally reach for a conversion node or fight the UI. This is that conversion node, with nothing else bolted on.

    Installing it

    It's part of ComfyUI-JakeUpgrade:

    • ComfyUI Manager โ†’ search "JakeUpgrade" โ†’ install โ†’ restart.
    • Or:
    cd ComfyUI/custom_nodes
    git clone https://github.com/jakechai/ComfyUI-JakeUpgrade
    cd ComfyUI-JakeUpgrade
    pip install -r requirements.txt
    

    Windows portable: run install.bat or ../../../python_embeded/python.exe -s -m pip install -r requirements.txt.

    Common issues

    • The result is one lower than I expected. See above - it's truncation, not rounding. If you genuinely need rounding, do it in a math node before converting (add 0.5 for positive values, then truncate), or use a Math operation that gives you a rounded result.
    • "I could just use ComfyUI's built-in convert." Sure - ComfyUI core has Convert Float to Int-style nodes in recent versions. But JakeUpgrade's math nodes (including its Float Binary Operation JK) emit floats, and this node is the sibling that pairs with them cleanly, especially if you're already running JakeUpgrade's workflows. It's a matter of what's already on your graph, not a capabilities arms race.

    It's a one-input, one-output triviality - the kind of node that looks silly until you're mid-workflow at 11pm and the only thing between you and a render is a FLOAT where an INT belongs.

    Category๐Ÿ‰ JK/โœ–๏ธ Math/๐Ÿ’  Conversion

    Inputs (1)

    NameTypeDefaultDescription
    aFLOAT0.00Input float value to convert

    Outputs (1)

    NameTypeDescription
    INTINTโ€”