Int Unary Operation JK๐
Negate, increment, square โ and the factorial that will bite you
- INT
CM_IntUnaryOperation applies one of eight operations to a single INT input (a) and returns an INT. The everyday ones are exactly what you'd expect: Neg (negate), Abs (absolute value), Inc (+1), Dec (โ1), Sqr (square), Cube. Then it reaches into the toolbox for Not and Factorial, and those two deserve a warning label.
The two traps
- Not is bitwise NOT - Python's
~a, which flips all the bits.~0is-1,~5is-6. If you came here looking for a logical "not a number is true/false," that's the wrong node entirely; it's a type mismatch, not a bug. For real boolean inversion use CM_BoolUnaryOperation, and for "is this zero" use the condition nodes. - Factorial runs
math.factorial(a), which is defined only for non-negative integers - feed it a negative and the node throws a ValueError and your queue dies. It also grows absurdly fast:factorial(20)is already a 19-digit number andfactorial(1000)is 2,568 digits. Nothing downstream wants that. It's a curiosity unless you're doing combinatorics-style scheduling (e.g., permutation counts), and even then you'll want to cap the input.
When you'd reach for it
Loop counters and schedulers are the sweet spot: Inc/Dec stepping a frame index, Sqr when you need quadratic falloff in a strength curve, Abs to normalize a signed delta before it hits a strength or percent input. If your graph does "increment by one each run" you could wire add-with-constant in the binary node, but Inc reads cleaner.
Installing it
Part of 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. Nothing to download.
Gotchas
- Factorial of a negative kills the run. Guard it: either clamp the input first or route through a condition so the factorial path only sees non-negative values.
- Not isn't logical not. The integer
Notis bitwise complement; mixing it up with boolean NOT is the most common misread in this node. - 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 (2)
| Name | Type | Default | Description |
|---|---|---|---|
| op | COMBO | Select unary mathematical operation | |
| a | INT | 0 | Input integer value |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| INT | INT | โ |