ComfyUI Node

Bitwise Xor

The bit-level toggle

By aria1th·Created 3 years ago·Updated 7 months ago· 116
Bitwise Xor
    • INT
    input10
    input20

    The third of the pack's bitwise-arithmetic trio, alongside And and Or: this one is ^, exclusive-or, on two integers. Where OR sets a bit if either input has it set, XOR sets a bit only if exactly one of the two inputs has it set - a bit stays off if both inputs agree (whether that's both on or both off), and flips on when they disagree.

    What it does

    Two required INT inputs, input1 and input2, both defaulting to 0. The node XORs them bit by bit and hands back a single INT. The property that makes XOR distinct from the other bitwise gates in this pack: it's its own inverse. XOR-ing a value with the same second value twice gets you back where you started (a ^ b ^ b == a), which is the classic trick behind toggle logic and simple bit-level encoding - flip a specific bit on, flip it off again with the identical operation, no separate "undo" needed.

    Realistic use in a ComfyUI context is the same as the rest of the bitwise family: reproducing packed-flag arithmetic, isolating or toggling specific bits in a value that's carrying more than one piece of information, or reversible lightweight scrambling of an integer. It's a specialist's node - most people who install this pack for the list and comparison utilities will never wire this one in, and that's expected.

    The inputs and outputs that matter

    • input1 (required INT, default 0) - the first value.
    • input2 (required INT, default 0) - the second value.
    • Output: INT - input1 ^ input2, bit by bit.

    Installing it

    Standard for the pack: ComfyUI Manager, search ComfyUI-LogicUtils, install, restart - or cd ComfyUI/custom_nodes && git clone https://github.com/aria1th/ComfyUI-LogicUtils by hand, then restart. No models, essentially no dependencies to speak of; this is the same pack that turned up in a Reddit thread as the recommended lightweight option specifically because it has nothing extra to install. There's an opt-in install hook behind COMFYUI_LOGICUTILS_AUTO_INSTALL=1, with COMFYUI_LOGICUTILS_SKIP_INSTALL=1 as a hard off switch - with nothing substantial in the repo to install in the first place, you're unlikely to ever need either.

    Where people get burned

    Same type strictness as its siblings: both ports are INT, not wildcard, so a float or string wired in gets rejected at connection time rather than coerced. If you're used to the pack's Compare or Or gates, which accept anything, it's an easy assumption to carry over incorrectly here.

    The other trap is conceptual rather than technical: XOR is not "not equal" in any general sense, even though it's tempting to use it that way. It's genuinely a bit-level operation - 5 ^ 3 doesn't tell you whether 5 and 3 are "different" in any meaningful sense beyond their binary representations disagreeing in specific positions. If what you actually want is "are these two values different," reach for the Compare gate elsewhere in this pack, which is built for that comparison and returns an actual BOOLEAN, not a number you have to interpret. As always with this pack, the source is the fallback reference - the README says plainly that full documentation hasn't caught up with the node count yet.

    CategoryLogic Gates

    Inputs (2)

    NameTypeDefaultDescription
    input1INT0
    input2INT0

    Outputs (1)

    NameTypeDescription
    INTINT