Nodes/ComfyUI-JDCN/LogicUtil_Bitwise Not
ComfyUI Node

LogicUtil_Bitwise Not

This is not 'invert the number' — LogicUtil_Bitwise Not does something weirder

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

    The one-line version

    LogicUtil_Bitwise Not flips every bit of an integer. In Python that means ~x, which is -x - 1, not -x. If you expected "negate my value," stop - the pack has a separate Negate Value node for that, and it behaves the way you'd expect. This one exists because bitwise NOT is a real tool for mask and flag math, and the pack wanted the complete set of bitwise gates.

    It's part of the LogicUtil family inside ComfyUI-JDCN, the same pack whose folder/file nodes keep getting recommended on r/comfyui for people juggling many files. LogicUtil is the pack's logic section, and the source credits aria1th's ComfyUI-LogicUtils as its origin.

    How it works

    An integer is stored as bits, and NOT turns every 0 into a 1 and every 1 into a 0. Because Python (and most modern languages) uses two's complement to represent negative numbers, the result isn't the friendly "opposite bits" you might imagine - it's -x - 1:

    • ~5-6
    • ~0-1
    • ~-10

    The implementation is literally one line: ~input1. No dependencies, no GPU, nothing hidden.

    Inputs and outputs

    • input1 (INT) - the integer to flip, default 0
    • Output: INT - the bitwise complement

    Single input, single output. Wire an integer in, take the complemented integer out.

    Installing it

    Same install as every node in this pack:

    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. Requirements are just piexif; no model downloads anywhere in this pack.

    Common issues

    • The result will look "wrong." The number one complaint with this node is someone feeding it 5, getting -6, and assuming it's broken. It isn't - that's what bitwise NOT does in two's complement. Use Negate Value if you want -5.
    • INT only. Bitwise ops reject floats. Feed it integers.
    • It's not a boolean NOT either. Invert Basic in the same pack is the "turn True into False" node. This one is for bit-level work.

    When you'd actually reach for it

    Honestly? Rarely, for most people. Bitwise NOT shows up when you're writing masks or inverting the bits of a packed flag integer - think custom sampler logic or exotic seed manipulation. If that's not you, the more useful members of this family are Bitwise And, Or, and Xor. But now you know what this one does, so the -6 won't scare you when it shows up in a shared workflow.

    CategoryLogicUtil

    Inputs (1)

    NameTypeDefaultDescription
    input1INT0

    Outputs (1)

    NameTypeDescription
    INTINT