Perform all bitwise operations (AND, OR, XOR, NOT, NAND, NOR, XNOR, shifts) on two numbers with step-by-step binary breakdown, bit grid visualization, and operations comparison table.
Bitwise operations are the building blocks of low-level programming, forming the foundation for everything from hardware design to efficient algorithms. Every processor executes these operations in a single clock cycle, making them the fastest possible computations a computer can perform. Understanding bitwise operations is essential for systems programming, embedded development, cryptography, graphics, and networking.
This combined bitwise calculator applies all major operations — AND, OR, XOR, NOT, NAND, NOR, XNOR, and bit shifts — to a pair of input numbers simultaneously. Instead of switching between separate tools, you see every operation's result side by side, making it easy to compare how different operations transform the same inputs.
The bit grid visualization displays each bit position with colour-coded results for AND, OR, and XOR, revealing the visual pattern of how each operation selects, combines, or differentiates bits. The comprehensive operations table shows every result in decimal, binary, and hexadecimal, while the quick reference table summarises each operation's purpose and common applications.
Whether you're debugging bitmask logic, studying for a computer science exam, or designing hardware, this all-in-one tool eliminates the need to run operations individually. Configure bit widths from 4 to 32 bits, adjust shift amounts, switch display bases, and use presets to explore classic bitwise patterns instantly.
Evaluating AND, OR, XOR, NAND, NOR, XNOR, NOT, and shifts for a pair of numbers by hand means writing out long binary columns for each operation — eight separate calculations that are tedious and error-prone. This calculator performs all of them at once and displays every result in decimal, binary, and hex alongside a colour-coded bit grid. Embedded firmware developers verify bitmask logic, digital-logic students compare truth-table outputs visually, and anyone debugging bitwise code can spot the wrong operation in seconds.
AND: both bits 1 → 1. OR: either bit 1 → 1. XOR: bits differ → 1. NOT: flip bit. NAND: NOT(AND). NOR: NOT(OR). XNOR: NOT(XOR). Left shift: A × 2ⁿ. Right shift: A ÷ 2ⁿ.
Result: AND=0, OR=255, XOR=255, NOT A=85, NAND=255, NOR=0
170 (10101010) and 85 (01010101) are complementary bit patterns. AND gives 0 (no shared bits), OR and XOR both give 255 (all bits), and NOT A equals B.
At the heart of every CPU sit eight operations that share a single trait: they work on each bit independently. **AND** outputs 1 only when both bits are 1 — used for masking and clearing bits. **OR** outputs 1 when at least one bit is 1 — used for setting bits. **XOR** outputs 1 when the bits differ — used for toggling and parity checks. **NOT** flips every bit — it computes the one's complement. From these four, the inverted gates follow: **NAND** = NOT(AND), **NOR** = NOT(OR), **XNOR** = NOT(XOR). Finally, **shifts** move all bits left or right, multiplying or dividing by powers of two.
Bit manipulation is ubiquitous in systems programming. **Flags and permissions** pack multiple booleans into a single integer; the Unix file-permission bits (rwxr-xr-x) are tested with AND masks. **Colour channels** in 32-bit ARGB values are extracted with masks and shifts: `(pixel >> 16) & 0xFF` gets the red channel. **Network protocols** use AND to compute subnet prefixes and XOR for checksums. **Encryption algorithms** like AES mix operations of XOR, shifts, and substitution. **Graphics shaders** lean on XOR and shifts for pseudo-random noise and hash functions. Even high-level algorithms benefit: XOR-swap saves a temporary variable, and Brian Kernighan's trick (`n & (n-1)` clears the lowest set bit) counts population (set bits) efficiently.
NAND and NOR are called *universal* gates because any Boolean function can be built from copies of just one of them. For example, NOT A = A NAND A, and A AND B = (A NAND B) NAND (A NAND B). Integrated circuits often use NAND-only or NOR-only implementations because manufacturing a single gate type is cheaper. Understanding these equivalences helps digital-logic students simplify circuits using Karnaugh maps or the Quine-McCluskey algorithm, and it gives programmers insight into how high-level expressions compile down to transistor-level logic.
Bitwise operations work on individual bits of integers. They include AND, OR, XOR, NOT, and shifts. Each operation has a truth-table-defined behaviour per bit position, applied simultaneously across all bits.
Processors have dedicated hardware (logic gates) for bitwise operations, executing them in a single clock cycle. They are faster than multiplication, division, and even addition in some architectures.
Bit masking uses AND with a "mask" value to isolate specific bits. For example, (value & 0xFF) extracts the lowest 8 bits. OR and XOR masks can set or toggle specific bits.
NAND is NOT(AND) — outputs 0 only when both inputs are 1. NOR is NOT(OR) — outputs 1 only when both inputs are 0. Both are universal gates (can build any logic from either alone).
Use AND to check if a bit is set or to clear bits. Use XOR to toggle specific bits. XOR flips the target bits while leaving others unchanged, while AND clears non-matching bits.
Use logical right shift (>>>) for unsigned values — it fills with 0s. Use arithmetic right shift (>>) for signed values — it preserves the sign bit, keeping negative numbers negative.