Nodes/ComfyUI-FairLab/Float To Int
ComfyUI Node

Float To Int

Truncation, not rounding — Float To Int drops the decimal and keeps the integer

By yanhuifair·Created 2 years ago·Updated 3 months ago· 2
Float To Int
    • value
    value

    ComfyUI is picky about types in ways that don't always make sense - some nodes want an integer where your logic chain is producing a float, and the graph just refuses to connect. Float To Int is the cast that fixes it: feed it a float, get an integer back, no questions asked.

    The one thing you need to internalize is that this node truncates, it does not round. The source is literally int(value), and Python's int() on a float chops off everything after the decimal point. So 3.7 becomes 3, and - here's the trap - 0.999 becomes 0. If you're converting a strength or a percentage into a step count or a dimension and you assumed it'd round to the nearest integer, you'll be off by one in ways that are maddening to debug. 1.91. Negative floats truncate toward zero too, so -3.7-3, not -4 (that's math.floor territory, which this node doesn't do).

    That truncation behavior is worth stating twice because it's the whole node. Want rounding instead? Round the value upstream, or do the math in a node that gives you both. FairLab's own Number node, for instance, emits round, ceil, and floor alongside its int - if you need proper rounding, that's the better source.

    Inputs and outputs are minimal:

    • value - a FLOAT input (wired from anywhere).
    • value - the truncated INT result.

    Where it fits in a workflow: it's the glue between the arithmetic layer and anything that needs a whole number - step counts, batch indices, image dimensions, seed handling. In the KB's node-plumbing taxonomy this is a type-cast node, part of the plumbing that keeps the graph type-correct without you hand-editing numbers.

    One practical note: this node is the type-cast sibling of Int To Float in the same pack, and both are also useful when a node's socket refuses a wire because the types don't line up. When ComfyUI's type checker says "can't connect FLOAT to INT," this is the adapter.

    Install is the standard pack path: ComfyUI Manager → search ComfyUI-FairLab → install → restart:

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

    Restart, search "Float To Int" or "cast int". No models, no dependencies, nothing that can fail except your expectations about rounding.

    CategoryFair/logic

    Inputs (1)

    NameTypeDefaultDescription
    valueFLOAT

    Outputs (1)

    NameTypeDescription
    valueINT