Nodes/ComfyMath/FloatToInt
ComfyUI Node

FloatToInt

Get a whole number out of a decimal one

By evanspearman·Created 3 years ago·Updated about a year ago· 192
FloatToInt
    • INT
    a0.00

    FloatToInt does exactly one thing: it takes a FLOAT and hands back an INT. That's the whole node. You won't look this one up because it impressed you - you look it up because you're stuck. Something upstream is outputting a float (a computed dimension, a duration, a ratio from a multiplication) and the node you actually want to feed only has a strict INT socket that refuses the wire. Rather than rebuild your math in a different type, you drop this in the middle and move on with your day.

    It earns its keep for a boring but real reason: ComfyUI's graph is typed at the socket level, and a FLOAT output cannot physically plug into an INT input, even when the value would convert cleanly. Something has to do that conversion, and that's this node's entire job description.

    How it works

    One input, a (FLOAT, default 0), one output (INT). It converts to a whole number and passes it downstream - no widgets, nothing to configure. Worth flagging honestly: neither the README nor anything else in the pack's docs says whether it rounds or truncates at a .5 boundary. If the exact value matters for your case, wire a preview node onto the output once and check rather than assuming.

    The inputs and outputs that matter

    • a - the float going in.
    • Output - a plain INT, ready for anything that wants a whole number: batch counts, frame counts, pixel dimensions, step counts.

    Installing it

    Search ComfyMath in ComfyUI Manager and install, or do it by hand:

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

    then restart ComfyUI. It's pure Python - no requirements.txt entries beyond what ComfyUI already ships, and no models to download. You'll have the node within a minute of hitting install.

    Common issues

    There isn't much surface area here to break, which is part of the appeal. The one real-world story worth knowing: a workflow author building an LTX-2 multi-frame video pipeline said their entire dependency on ComfyMath was "just because of silly float/int conversion for framerate" - exactly this problem, a node computing a float where the next one insists on an int. That's this node's real job in the wild, not a hypothetical.

    Two things to keep in mind. First, ComfyMath's author hasn't been actively maintaining the repo since at least early 2024 - someone asking for a feature addition on Reddit was told plainly that "the ComfyMath's author no longer work on the project." In practice this hasn't caused problems: it's plain arithmetic with zero external calls and no model dependency, so there's very little for a ComfyUI update to break. But don't expect a quick fix if something ever does.

    Second, don't mix this up with ComfyMath's own NUMBER type, used by its NumberBinaryOperation and NumberUnaryOperation nodes. FloatToInt speaks ComfyUI's native FLOAT/INT sockets only - if you're chaining ComfyMath's NUMBER-typed nodes together, you want FloatToNumber instead, not this one, because a plain INT socket and a NUMBER socket aren't interchangeable even though they hold the same kind of value.

    Categorymath/conversion

    Inputs (1)

    NameTypeDefaultDescription
    aFLOAT0.00

    Outputs (1)

    NameTypeDescription
    INTINT