Number2Int_AS
Round any number to an integer, and make it fit an int socket
- value
- INT
Number2Int_AS takes a number and outputs it as an INT, rounding to the nearest whole value along the way. It solves two problems at once: making a float physically fit an int socket, and cleaning up fractional values so a steps count or a seed actually makes sense.
It's part of flyingshutter's As_ComfyUI_CustomNodes, a dependency-free playground pack. No models, no requirements.txt, nothing extra to install.
How it works
ComfyUI's number type accepts both ints and floats. This node rounds whatever comes in with Python's round() and outputs it as INT. So 3.14159 becomes 3, 4.6 becomes 5, and an int that arrives stays exactly itself (rounding an int is a no-op). Unlike its sibling Number2Float_AS - which just relabels a value as a float - this one genuinely transforms the data, because an int port physically cannot carry a fraction.
The round() behavior is worth one sentence: Python uses banker's rounding on exact .5 values, so round(2.5) gives 2 and round(3.5) gives 4. It rarely bites, but if you're surprised by a result one off from your mental math on exact halves, that's the reason.
The inputs
value- anynumber(int or float). Output:INT(rounded).
That's the whole interface.
Where you'd use it
ComfyUI is full of float-only outputs from nodes you'd love to feed into int inputs - resolution, batch size, steps, offsets, tile counts. A calculation gives you 7.94 and the node you're feeding demands a whole number of steps; this rounds it and makes the socket legal in one move. It also pairs naturally with Math_AS or MapRange_AS from this pack: compute a ratio or a remapped value, then round it down here before wiring it into a sizing input.
It's the kind of quiet utility that unblocks a workflow rather than adding visible features.
Installing it
cd ComfyUI/custom_nodes
git clone https://github.com/flyingshutter/As_ComfyUI_CustomNodes
Restart ComfyUI and it's under ASNodes (or ComfyUI Manager → "As_ComfyUI_CustomNodes"). No extra dependencies.
Common issues
- Banker's rounding surprises. Exact .5 values round to the nearest even number, not always up. If that matters for your math, note it.
- It rounds, it doesn't floor. If you need
int(7.9) == 7(floor) rather than8, this node won't do it - you'd want a floor operation. Same for ceiling. - Big precision loss. Rounding a 3.14159 weight to 3 for a LoRA scale is a real change in behavior. Only round where the downstream actually needs whole numbers.
Simple, predictable, and genuinely useful whenever float-land and int-land need to meet.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| value | number | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| INT | INT | — |