๐ข Math Int
Integer math for people who are tired of hand-counting
- result
ComfyUI ships math operations buried inside a few oddly-shaped nodes, and when you're mid-workflow and just want to add 1 to a counter, hunting for the right one is a chore. InitialBMathInt is the plain version: two integers in, one integer out, pick your operation from a dropdown. It's the sort of node that isn't exciting until you realize the for-loop machinery in this same pack uses it internally - so it's also the best building block for index arithmetic.
The inputs
aandb- the two integers. No min/max bound in the schema, so they're plainINTs.operation- the dropdown, with six choices:add,subtract,multiply,divide,modulo,power.
Output is result (INT). That's the whole API.
What each operation actually does
add/subtract/multiply- exactly what they say.divide- integer (floor) division, the//operator, not floating-point.7 // 2is3, not3.5. If you need fractions, this isn't the node.modulo- the remainder,a % b. Great for patterns:index % Ngives you a value that cycles 0..N-1.power-a ** b. Watch out: this can overflow fast.2 ** 100is not something you want feeding a loop counter.
Two safety behaviors worth knowing: divide and modulo return 0 instead of crashing when b is 0. It won't save you from bad logic, but it saves you from a workflow that dies on a zero input, which is a small mercy in a language where every node runs every time.
Why you'd actually use it
The realistic jobs:
- Inside loops (this pack's For/While Loop pair, or any iteration): an index counter is
a + 1, a "which frame of a 4-frame pattern" isindex % 4, a page number isindex // batch_size. - Parameter math: turning a seed into a shifted seed, computing a step count, deriving one value from another when you only have integers.
- Building conditions: combined with a Compare node, arithmetic is how "should I stop the while loop yet?" gets answered.
It's the integer cousin of the pack's Range Int node - one generates sequences, the other transforms individual values, and together they cover most of the "do math in a graph" need.
Install
Pack: InitialB Util. In ComfyUI Manager, search "InitialB Util" โ Install, or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/benjiyaya/Comfyui_InitialB_Util
cd Comfyui_InitialB_Util
pip install -r requirements.txt
Restart ComfyUI. No models, no heavy deps - requirements.txt is torch/numpy/scipy/Pillow, already present. Note the README's clone URL is a placeholder; use the real repo above or Manager. You'll find the node under InitialB/utility.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| a | INT | 0 | โ |
| b | INT | 0 | โ |
| operation | COMBO | add | 6 options: add, subtract, multiply, divide, modulo, power |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| result | INT | โ |