规范数值🐠meeeyo.com
Stop fighting ComfyUI over int vs float — round, ceil, floor, or snap to 32
- any
- INT
ComfyUI is picky about types. Loaders and samplers want INT on some ports, arithmetic nodes give you FLOAT, and the wire turns red (or won't connect at all) until you fix it. FloatToInteger (规范数值 - "normalize the number") is the tiny referee: it takes any FLOAT and returns a clean INT, with four different rounding strategies. The name in the UI is "normalize" because in the pack author's workflow this mostly feeds widths, heights, and batch counts that have to be exact integers.
How it works
Two inputs: float_value (a FLOAT) and operation, a dropdown with four choices:
- 四舍五入 - round to nearest integer (Python banker's rounding: 2.5 → 2, 3.5 → 4)
- 取大值 - always round up (
ceil) - 取小值 - always round down (
floor) - 最近32倍 - round to the nearest multiple of 32
The last one is the pack's signature move. Why 32? Because diffusion models - SDXL, Flux, Wan, most video models - expect latent dimensions divisible by 8, and a whole family of workflows uses 32 as the safe "can't be wrong" step. Instead of a math node chain to compute round(x/32)*32, this is one dropdown. If you've ever had a ValueError because your latent was 511 wide instead of 512, you already know why this exists. It's the same snap-to-grid thinking the image tools in this pack use (see ImageAdjuster's Million Pixels mode, which snaps to multiples of 8).
Output is a single INT. Wire it straight into a width, height, batch size, steps, or seed port.
Where it fits
It's one of the pack's two number-utility nodes (the other is GenerateNumbers, for building ranges). The workflow that justifies it: you compute an aspect-ratio-derived dimension as a float, and you need an int that the VAE won't choke on. Or you're chaining a random float and need a clean seed. It's not glamorous, but it's the difference between "workflow works" and "workflow errors on queue."
Install
Part of the ComfyUI_StringOps pack:
cd ComfyUI/custom_nodes
git clone https://github.com/MeeeyoAI/ComfyUI_StringOps.git
Restart. Or ComfyUI Manager → search "ComfyUI_StringOps". No model downloads; the pack's deps (numpy, torch, Pillow, openpyxl, requests, chardet, pytz, ntplib) are standard. UI is Chinese-labeled (规范数值) with the usual 🐠meeeyo.com branding and the author's contact ad in the description.
Common issues
The main thing to know is which rounding you actually asked for. People pick "round" expecting classic round-half-up and get Python's banker's rounding instead - for the values you'll feed as dimensions this rarely matters, but for a batch count of exactly x.5 it can be a one-off surprise. And the "nearest 32" mode is genuinely different: max_dimension-style math where 64 → 64 but 80 → 96, not 80. If you need a hard clamp, floor, then snap, do it in two passes.
Also worth noting: there's no "keep it a float" branch. If your downstream port genuinely needs FLOAT, this isn't the node - but most "why won't this connect" problems are the opposite, an int being demanded where a float lives. This is the bridge.
Tiny, boring, and it quietly unblocks a dozen workflows. That's the whole job.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| float_value | FLOAT | 3.14 | — |
| operation | COMBO | 四舍五入 | 4 options: 四舍五入, 取大值, 取小值, 最近32倍 |
| anyopt | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| INT | INT | — |