Compute bitwise AND, OR, NOT, NAND, NOR, and XNOR operations on binary numbers
Try an example:
Tip: Inputs are automatically padded to match lengths. For NOT operations, only Input A is used. Results show both binary and hexadecimal values.
Bitwise operations work directly on the binary representation of numbers, processing each bit independently. If you've worked with low-level programming, embedded systems, or network protocols, these operations are part of your daily toolkit. Even if you're just getting started with binary logic, understanding AND, OR, and NOT is the foundation for everything else in digital computing.
AND — Returns 1 only when both input bits are 1. Think of it as a gate that says "both conditions must be true." In real-world debugging, AND is what you use when you want to mask specific bits and check whether they're set. 1100 AND 1010 = 1000 because only the leftmost bit is set in both inputs.
OR — Returns 1 when at least one input bit is 1. This is the "any condition is true" gate. If you're setting a configuration flag and want to enable multiple features at once, OR is your operation. 1100 OR 1010 = 1110 because every bit that's set in either input stays set.
NOT — Flips every bit. It's the simplest operation: each 0 becomes 1, and each 1 becomes 0. NOT is a unary operation, meaning it only needs one input. NOT 1100 = 0011. In programming, NOT is how you invert a flag or turn off every bit that was previously on.
Here are the complete truth tables for every operation this calculator supports. Each table shows what happens for every possible pair of input bits (A and B), or in the case of NOT, for every possible input bit.
| A | B | AND | OR | NAND | NOR | XNOR |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 0 |
| 1 | 0 | 0 | 1 | 1 | 0 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 1 |
| A | NOT A |
|---|---|
| 0 | 1 |
| 1 | 0 |
Note: NAND = NOT AND (invert AND result), NOR = NOT OR (invert OR result), XNOR = NOT XOR (1 when both bits are equal).
chmod masks are bitwise AND operations).-x = NOT(x) + 1.This is a distinction that trips up a lot of beginners, so it's worth spelling out clearly.
Bitwise operators (&, |, ~ in most programming languages) operate on each bit of their operands independently. Given two 8-bit numbers, a bitwise AND produces another 8-bit number where each bit is computed from the corresponding bits of the inputs. The result is a number.
Logical operators (&&, ||, ! in C-family languages) operate on boolean values (true/false). They treat their operands as either "truthy" or "falsy" and return true or false. In JavaScript, 5 & 2 evaluates to 0 (bitwise AND), but 5 && 2 evaluates to 2 (logical AND short-circuits and returns the second truthy value).
I've seen plenty of production bugs caused by using bitwise AND when logical AND was intended, or vice versa. When you're writing things like if (flags & MASK) — that's a bitwise operation checking if specific bits are set. But if (condition1 && condition2) is a logical operation checking if both conditions are true at the boolean level. Different tools, different jobs.