ComfyUI Node

Float to Integer

Turn a decimal into a whole number, your way

By jamesWalker55·Created 3 years ago·Updated about a year ago· 215
Float to Integer
    • INT
    value0.00
    mode

    You hit this node the moment a float has to feed something that only accepts an integer. Width and height want whole pixels. steps and batch_size want whole counts. But the value you're carrying - maybe it came out of a multiply, or a ratio, or a slider - is a float like 768.0 or 511.6. JWFloatToInteger converts a FLOAT to an INT, and crucially lets you choose how the rounding happens.

    That "how" is the reason this node exists rather than a silent auto-cast. Should 511.6 become 512 or 511? Depends what you're doing, and getting it wrong by one pixel can throw off a resolution that needed to stay divisible by 8 or 64. This node makes the decision explicit instead of leaving it to chance.

    How it works

    It takes your float and applies one of three rounding rules, then emits an integer:

    • round - nearest whole number (511.6512, 511.4511).
    • floor - always down (511.9511).
    • ceiling - always up (511.1512).

    Pick the one that matches your intent. For "snap to the closest sensible size," round. For "never exceed this limit," floor. For "make sure it's at least this big," ceiling.

    The inputs and outputs that matter

    • value (FLOAT) - the decimal to convert. Default 0.
    • mode (enum: round / floor / ceiling) - the rounding rule. This is the knob that actually matters; the default behaviour is round, and most of the time that's what you want.
    • Output: INT - the whole number, ready for any integer socket (dimensions, steps, batch size, an index).

    How to install it

    Part of jamesWalker55/comfyui-various, a pack of small utility nodes.

    • ComfyUI Manager: search "Various ComfyUI Nodes by Type", install, restart. Came in red with a downloaded workflow? Use Install Missing Custom Nodes.
    • Manually:
      cd ComfyUI/custom_nodes
      git clone https://github.com/jamesWalker55/comfyui-various
      
      Restart afterward. No models, no dependencies.

    Look for it under the jamesWalker55 category after restart.

    Common issues

    • Off-by-one pixel dimensions. If a resolution ends up one pixel off what a model wants (SDXL and most latents like dimensions divisible by 8 or 64), your rounding mode is the usual culprit. If you multiplied a size by a ratio and need the result to stay a clean multiple, do the divisibility math in float first, then convert - or feed the integer into a node that snaps to a valid resolution.
    • "It rounded a value I didn't want rounded." By definition, converting float→int loses the fractional part. If you need the decimals downstream, don't convert; keep it a float until the last possible moment.
    • Node is red / missing. The pack isn't installed. Grab it through Manager or clone the repo, then restart ComfyUI fully.

    This is a one-way door - once you're an integer, the .6 is gone. Convert as late in the chain as you can, so the precision lives as long as it's useful.

    CategoryjamesWalker55

    Inputs (2)

    NameTypeDefaultDescription
    valueFLOAT0.00-100000000000000000–100000000000000000
    modeCOMBO3 options: round, floor, ceiling

    Outputs (1)

    NameTypeDescription
    INTINT