Int Math | Basic
Integer math plus the bitwise operators nobody else gives you
- INT
IntMath ("Int Math | Basic") is the integer-only cousin of BasicMath, and it's the one you want when every value involved is a whole number and you don't want the result silently becoming a float. It takes two INT inputs, a and b, applies an operation, and always hands back an INT.
Where it earns its keep is the operator list. Beyond the usual +, -, *, //, %, **, min, and max, it includes the four bitwise operators: & (AND), | (OR), ^ (XOR), and the shift operators << and >>. Those are the odd ones out in the ComfyUI world - almost no other pack exposes them as graph nodes.
The inputs that matter
- a, b - integers, each with a range of roughly ±9.2 quintillion (the full 64-bit signed range) and a step of 1.
- operation - all 13 choices. The bitwise ones are the reason to pick this over
BasicMath:&and|are great for merging or masking integer flags, and<</>>are how you multiply or divide by powers of two in one step.
Output is INT, always. No float leakage.
Why you'd reach for it
Three honest use cases. First, stepping through grid or tile layouts: computing x + width to walk across an image batch stays integer, which keeps downstream size math clean. Second, seed and flag work: seed & 0xFF to derive a variant seed, or | to combine toggle bits, are one node away. Third, any place where BasicMath's float-leaning behavior would force you to add a conversion - IntMath never does.
The behavior differences worth knowing
There is deliberately no / here, only // - integer division, so 7 // 2 gives 3. And it's not shy about failure: unlike BasicMath, which returns infinity or nan on division by zero, IntMath just returns 0. It won't crash your graph either way, but a silent 0 can be a nastier bug to track down than a screaming inf, so keep that in mind if you're dividing values that could be zero. That's the one edge case I'd clamp before it reaches this node.
Installing it
Standard pack install, zero dependencies - it's all Python's standard library:
cd ComfyUI/custom_nodes
git clone https://github.com/akatz-ai/ComfyUI-Basic-Math
Restart ComfyUI, and it's under Basic Math ➕ → Arithmetic as "Int Math | Basic". Or use ComfyUI Manager → Install Custom Nodes → search "ComfyUI-Basic-Math".
The gotchas
The ^ operator is XOR, not exponent - exponent is **. That's a classic foot-gun for anyone coming from spreadsheet math. And remember the output is always an INT: if you plug a float into a or b, the socket will refuse it (this node is strictly INT-only, unlike BasicMath's flexible NUMBER ports). When you need mixed types, that's what BasicMath is for.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| a | INT | 0-18446744073709550000–18446744073709550000 | — |
| b | INT | 0-18446744073709550000–18446744073709550000 | — |
| operation | COMBO | 13 options: +, -, *, //, %, **, +7 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| INT | INT | — |