ComfyUI Node

Float to Integer

It says it rounds. It doesn't. Know the difference.

By HavocsCall·Created 2 years ago·Updated 9 months ago· 4
Float to Integer
    • Integer
    Float

    Float to Integer converts a FLOAT to an INT. Simple conversion node, one input, one output. But here's the wrinkle that makes this worth a warning: the node's own description says "Rounds," and the README says it truncates. The code - which is ground truth - truncates toward zero. 3.7 becomes 3, and -3.7 becomes -3, not -4 as rounding would give you.

    When you'd use it

    ComfyUI is full of places where one side of the graph wants an integer and the other side hands you a float - dimensions, step counts, batch sizes, seeds, counters. A conversion node is the adapter. If you're computing a value (via a math node, a comparison, a percentage of something) and the thing you're feeding insists on INT, this is the bridge.

    How it works

    The actual implementation is one line:

    result = int(Float)
    

    That's Python's int() on a float, which truncates toward zero. If you genuinely need rounding - 3.74 - this is not your node, and the mismatch between the description and the behavior is a classic "trust the code, not the label" moment. The Math Operation node in this same pack has a "Round" mode if that's what you actually want.

    Inputs:

    • Float - a FLOAT input socket (forceInput, so wire it, don't type).

    Output:

    • Integer - the truncated INT.

    Where people get burned

    Beyond the rounding surprise, the subtle one is precision loss in the other direction of the pipeline: if you convert early, you lose the fractional part before later math ever sees it. Convert at the last moment - right before the node that needs the integer - and let upstream stay in float land as long as possible.

    Also worth knowing: the conversion node family in this pack (Float to Integer, Integer to Float, Integer to String, and the string-conversion siblings) all share the forceInput pattern, so none of them accept typed values. Everything comes from wires.

    Installing it

    ComfyUI Manager → search "HavocsCall" → install → restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/HavocsCall/comfyui_HavocsCall_Custom_Nodes
    

    Restart, under HavocsCall/Conversion. No requirements.txt, no model downloads - instant.

    CategoryHavocsCall/Conversion

    Inputs (1)

    NameTypeDefaultDescription
    FloatFLOAT

    Outputs (1)

    NameTypeDescription
    IntegerINT