LogicUtil_Bitwise And
Bitwise AND is how you check or clear flags — LogicUtil_Bitwise And explained
- INT
The one-line version
LogicUtil_Bitwise And takes two integers and returns the result of a bit-by-bit AND on their binary representation. If you've never needed bitwise math in a diffusion workflow, this node is probably not for you - but if you're packing flags, seeds, or per-channel values into a single integer, it's the tool. And it's the first place to look when you're handed a workflow where someone hides a bunch of toggles inside one number.
It comes from the LogicUtil family inside ComfyUI-JDCN, the utility pack best known for its folder and file-handling nodes. LogicUtil is the pack's logic-gates section, credited to aria1th's ComfyUI-LogicUtils in the source. Nothing here downloads a model, needs a GPU, or calls an API - it's pure integer math that runs in microseconds.
How it works
AND works on the individual bits (0s and 1s) of both numbers, from the least significant bit up. Each bit of the output is 1 only if both inputs have a 1 in that position. Concretely:
12 & 10→12is1100,10is1010, AND gives1000→87 & 5→111 & 101→101→56 & 1→110 & 001→0
The source is one line: input1 & input2. That's the entire mechanism - the & operator in Python, exposed as a node.
Inputs and outputs that matter
input1(INT) - the first integer, default 0input2(INT) - the second integer, default 0- Output: INT - the bitwise AND
Only two inputs to worry about. Wire any integer-producing node - a seed, a counter, an arithmetic result - into both, and the INT output feeds wherever you need the combined value.
Installing it
The whole pack installs at once; there's no per-node install.
Easiest - ComfyUI Manager: click Manager, then Install Custom Node, search for ComfyUI-JDCN, install, restart.
Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/daxcay/ComfyUI-JDCN.git
cd ComfyUI-JDCN
pip install -r requirements.txt
Then restart ComfyUI. The only dependency is piexif (for the pack's image/EXIF tools - this node itself needs nothing). No model files to download.
Common issues
- It's INT-only. Bitwise operators don't work on floats. If you feed a float in, Python raises
TypeErrorand the queue errors. Keep these nodes fed from integer sources. - Confusing it with a boolean AND. This is not
True and True. If you want to check "are both of these conditions true," that's a comparison node, not this one. Bitwise AND is for integer flags and masks. - It doesn't show in the default menu under a friendly name. Search the node menu for "Bitwise" or look under the LogicUtil category. Display names in this family are all prefixed
LogicUtil_.
When you'd actually reach for it
Encode a set of on/off flags as powers of two (1, 2, 4, 8…), store the sum, then flag & 4 tells you whether flag #3 is set. That's the classic use, and it's a neat way to compress a control panel down to a single integer you can pass around a graph. For everyone else: it's fine to ignore this one until a workflow hands it to you.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| input1 | INT | 0 | — |
| input2 | INT | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| INT | INT | — |