Bitwise Calculator

Compute AND, OR, XOR and NOT on integers in decimal, hex or binary.

Ad placeholder (leaderboard)

A bitwise calculator applies Boolean logic to each pair of bits in two integers. These operations are the foundation of flags, bitmasks, permissions, checksums and low-level protocol work. This tool accepts decimal, hex or binary input and shows the result in all three bases.

How it works

Each operation compares the operands bit by bit:

  • AND (&) — result bit is 1 only when both input bits are 1. Used to mask/clear bits.
  • OR (|) — result bit is 1 when either input bit is 1. Used to set bits.
  • XOR (^) — result bit is 1 when the input bits differ. Used for toggling and parity.
  • NOT (~) — flips every bit of operand A.

Because NOT and signed values depend on register size, the result is masked to your chosen width with mask = (1 << width) - 1. So NOT of an 8-bit value inverts exactly 8 bits.

Example

With A = 0b1100 (12) and B = 0b1010 (10):

  • A AND B = 0b1000 = 8
  • A OR B = 0b1110 = 14
  • A XOR B = 0b0110 = 6
  • NOT A (8-bit) = 0b11110011 = 243

Notes

Common idioms: set bit n with x | (1 << n), clear it with x & ~(1 << n), toggle it with x ^ (1 << n), and test it with x & (1 << n). The width selector lets you reproduce the exact wraparound behaviour of a fixed-size register.

Ad placeholder (rectangle)