M Int Div Floor (a // b)
Aspect-ratio math without fractions
- a_div_b_floor
Integer division is the unglamorous workhorse of ComfyUI math, and M Int Div Floor is the honest version of it. a divided by b (defaults 0 and 1), with the result rounded down to a whole number - Python's floor division, a // b - returned as a_div_b_floor. No floats, no rounding surprises; if you need "how many times does this fit into that" as an integer, this is the node.
The real-world uses are the tile and grid ones:
- Aspect-ratio scaling. Need a height that keeps a 16:9 ratio but lands on an integer? Width divided by a fixed ratio constant gives you the base, then a multiply-and-clamp chain finishes the job.
- Tiling. "How many 512 tiles fit along a 2000px image?" -
a_div_b_flooranswers exactly that, and the remainder is what the pack's M Int DivMod node hands you alongside it. - Batch/loop math. Splitting a count into groups of N needs integer division, and floor semantics (not truncation toward zero) matter when negatives are in play - floor division handles those the way you'd expect from school math, not the way a C programmer would expect.
One behavior to know before it bites you: divide by zero doesn't crash - the node returns 0 instead. That's a deliberate safety choice in the code, and it's friendlier than an exception mid-run, but it's also silently wrong if you ever wire a zero divisor in by mistake. If that matters to your workflow, guard the divisor upstream.
Inputs a and b are plain INT sockets (signed 32-bit), output is a single INT. It composes with the pack's mul/add nodes for multi-step calculations.
It ships in ComfyUiNodes (repo Madlumi/ComfyUiNodes, author "Madanie"), a small pack of integer math, string, and workflow-glue nodes. Install via ComfyUI Manager - search "ComfyUiNodes" - or:
cd ComfyUI/custom_nodes
git clone https://github.com/Madlumi/ComfyUiNodes
Then restart ComfyUI. No pip requirements or model downloads. Find it under Add Node → mnodes → int.
If the "safe zero" behavior bugs you, that's fair - but for tiling and aspect math, this node is the cleanest way to keep everything in integers.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| a | INT | 0-2147483648–2147483647 | — |
| b | INT | 1-2147483648–2147483647 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| a_div_b_floor | INT | — |