Nodes/ComfyUI-JDCN/LogicUtil_Bitwise Or
ComfyUI Node

LogicUtil_Bitwise Or

Setting flags without collisions — LogicUtil_Bitwise Or, the OR you actually want

By daxcay·Created 2 years ago·Updated about a year ago· 159
LogicUtil_Bitwise Or
    • INT
    input10
    input20

    The one-line version

    LogicUtil_Bitwise Or takes two integers and ORs their bits together: an output bit is 1 if either input has a 1 in that position. It's the bitwise counterpart of "add these flags up without double-counting," and it's the natural pair to Bitwise And in this pack - And checks which bits are set, Or sets them.

    It ships in ComfyUI-JDCN, a pack that's mostly famous for its folder/file utilities (the JDCN_* nodes people recommend on r/comfyui for directory-based image loading). The LogicUtil section is the pack's little logic toolbox, credited in the source to aria1th's ComfyUI-LogicUtils.

    How it works

    OR compares each bit position independently. A 1 in either input makes the output 1:

    • 12 | 101100 | 1010111014
    • 5 | 3101 | 0111117
    • 8 | 11000 | 000110019

    The whole node is input1 | input2 - Python's bitwise OR operator, wrapped as a node. Nothing heavier.

    Inputs and outputs

    • input1 (INT) - first integer, default 0
    • input2 (INT) - second integer, default 0
    • Output: INT - the bitwise OR

    Two integer inputs, one integer output. Feed it seeds, counters, or the output of another arithmetic node.

    Installing it

    Standard pack install, once:

    Easiest - ComfyUI Manager → Install Custom Node → search 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
    

    Restart ComfyUI. The only dependency in the whole pack is piexif, and there are zero model downloads.

    Common issues

    • INT only, again. Bitwise operators raise TypeError on floats. Integer sources only.
    • Or vs And confusion. Or sets bits, And tests them. If you're building a flag system: flags | 4 turns on bit 3; flags & 4 asks if it's on. Mixing them up produces masks that look right and behave wrong.
    • Not the same as LogicUtil_AOrBGate. That node is a boolean gate (and, fair warning, check the notes on that one before trusting the name). This is the integer bit-level OR.

    When you'd actually reach for it

    Flag packing. If you keep a single integer as a bundle of on/off options (bit 0 = one option, bit 1 = another, …), OR is how you turn options on without disturbing the ones already set. It's also useful in any creative seed-scrambling where you want to merge two numbers' bit patterns. Outside that, it's a "nice to have in the toolbelt" node - most workflows won't need it, but it's cheap to keep around.

    CategoryLogicUtil

    Inputs (2)

    NameTypeDefaultDescription
    input1INT0
    input2INT0

    Outputs (1)

    NameTypeDescription
    INTINT