Nodes/ComfyUI-JDCN/LogicUtil_Round
ComfyUI Node

LogicUtil_Round

Snap a float to a whole number, and know it's banker's rounding

By daxcay·Created 2 years ago·Updated about a year ago· 159
LogicUtil_Round
  • input1
  • INT

Half of ComfyUI's "why won't this widget accept my value" problems are floats where an int is required. LogicUtil_Round is the one-node fix: input1 in, and a clean INT out, rounded to the nearest whole number. It's the quiet, unglamorous node that unblocks integer-only fields on samplers, counters, and step widgets.

How it works

One input, input1, typed * so it accepts anything numeric. The output is INT, produced by Python's built-in round(). And here's the thing worth knowing before it surprises you: Python rounds ties to even. round(2.5) is 2, not 3, and round(3.5) is 4. Most people learned "round half up" in school and spend a confused minute when 2.5 lands on 2. For image work the difference is cosmetic - snapping a denoise of 0.25 to a resolution divisor never hinges on a tie - but if you're building exact math, know which rounding you're getting.

The type gotcha is the same one that runs through the whole family: input1 is a * wildcard, so the graph won't stop you from feeding it a string, and round("cat") is a TypeError at queue time. Keep it numeric.

The uses are the boring ones that every workflow secretly needs:

  • Widget compatibility. Compute a float (say, from Multiply or Power) and round it before it has to slot into an INT field that rejects decimals.
  • Step sizing. Round an upscale dimension to a multiple-friendly value before it hits a resize node.
  • Frame math. Round a duration to a whole number of frames so your animation doesn't drift.

It composes cleanly with the rest of the family: Multiply to scale, Round to snap, Min/Max to clamp - that's the standard "make an arbitrary value safe to feed a strict widget" chain. Round is part of the LogicUtil family, a port of aria1th's ComfyUI-LogicUtils riding inside the JDCN pack from Daxton Caylor and Jerry Davos. The pack's README covers the file and latent batch nodes and ignores this family, so the source is the doc: one input, round(), one INT out.

Install

Install is the standard JDCN routine: ComfyUI Manager → "Install Custom Node" → search JDCN → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/daxcay/ComfyUI-JDCN
cd ComfyUI-JDCN && pip install -r requirements.txt

Only piexif on the requirements list, no models to fetch. And when rounding "goes the wrong way" on a .5, remember: ties to even, not ties up. It's not broken, it's Python.

CategoryLogicUtil

Inputs (1)

NameTypeDefaultDescription
input1*

Outputs (1)

NameTypeDescription
INTINT