Int Binary Operation JK๐
Sixteen integer operations, including the ones that bite
- INT
CM_IntBinaryOperation is the pack's integer arithmetic workhorse: an op dropdown with sixteen operations applied to two INT inputs (a, b), one INT output. It covers the everyday stuff - add, subtract, multiply - and then a layer of operations that will happily surprise you if you assume they work like a calculator.
The operation menu, and where the traps are
- Add, Sub, Mul - the basics.
- Div - integer floor division.
7 / 2gives3, not3.5. This is the number-one gotcha: the float twin does real division, the int version chops it. - Mod - remainder. Pairs with Div for "does b divide a evenly" logic.
- Pow - exponentiation,
a ** b. - And, Nand, Or, Nor, Xor, Xnor - bitwise operations (
&,|,^), not logic gates.5 And 3is1, because 101 & 011 = 001. If you wanted boolean AND, that's the dedicated Bool nodes - these operate on the bits of the numbers. - Shl, Shr - bit shifts. A left shift is a multiply-by-two, a right shift a floor-divide-by-two. Niche, but the fastest way to build powers of two.
- Max, Min - clamp to the larger/smaller of the two. More useful than it looks:
Max(x, 0)is a floor,Min(x, 100)is a ceiling.
When you'd reach for it
Seed math (derive a batch of seeds from one base), frame/step arithmetic in video loops, clamping values before they reach a sampler, or building an index. The bitwise ops are the ones that turn up in clever looping patterns - an XOR, for example, toggles between two states when fed a counter.
Installing it
Ships with ComfyUI-JakeUpgrade:
cd ComfyUI/custom_nodes
git clone https://github.com/jakechai/ComfyUI-JakeUpgrade
cd ComfyUI-JakeUpgrade
# Windows standalone: install.bat
# or: python_embeded\python.exe -s -m pip install -r requirements.txt
pip install -r requirements.txt # non-Windows
Or ComfyUI Manager, search "JakeUpgrade", install, restart.
Gotchas
- Div truncates. Mixing ints and expecting
3.5is the classic error; convert with CM_IntToFloat first if you need real division. - Bitwise And/Or are not logic gates. The names collide with the boolean nodes on purpose and it's a footgun - check the category (๐ก Int vs ๐ฅข Bool) before you trust the output.
- Shl/Shr on negatives get weird in two's complement. For counting/index work, keep inputs non-negative.
- Manager's JakeUpgrade / IPAdapter_plus conflict warning is a false positive from the pack's
replacement/folder. - ComfyUI-MultiGPU causes CUDA errors with recent ComfyUI; disable it per the README.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| op | COMBO | Select binary mathematical operation | |
| a | INT | 0 | First integer input |
| b | INT | 0 | Second integer input |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| INT | INT | โ |