Every truth table, every bit hack, every shift pattern — one page. For embedded devs, systems programmers, and anyone who works close to the metal.
| A | B | A&B |
|---|---|---|
| 1 | 1 | 1 |
| 1 | 0 | 0 |
| 0 | 1 | 0 |
| 0 | 0 | 0 |
1 only if both are 1
Use: bit masking / flag check
| A | B | A|B |
|---|---|---|
| 1 | 1 | 1 |
| 1 | 0 | 1 |
| 0 | 1 | 1 |
| 0 | 0 | 0 |
1 if either is 1
Use: set bits / combine flags
| A | B | A^B |
|---|---|---|
| 1 | 1 | 0 |
| 1 | 0 | 1 |
| 0 | 1 | 1 |
| 0 | 0 | 0 |
1 only if bits differ
Use: toggle / swap / parity
| A | ~A |
|---|---|
| 1 | 0 |
| 0 | 1 |
Flips every bit
Use: bitwise complement
| A | B | ~(A&B) |
|---|---|---|
| 1 | 1 | 0 |
| 1 | 0 | 1 |
| 0 | 1 | 1 |
| 0 | 0 | 1 |
Universal gate in hardware
Use: CPU logic circuits
| A | B | ~(|) |
|---|---|---|
| 1 | 1 | 0 |
| 1 | 0 | 0 |
| 0 | 1 | 0 |
| 0 | 0 | 1 |
Also a universal gate
Use: CPU logic circuits
| A | B | ~(^) |
|---|---|---|
| 1 | 1 | 1 |
| 1 | 0 | 0 |
| 0 | 1 | 0 |
| 0 | 0 | 1 |
1 only if bits are equal
Use: equality check
Arithmetic right shift (>>) preserves sign bit (MSB). Logical right shift (>>>) always fills with 0.
Left shift (<<) always fills with 0 regardless of signedness.
| Precedence | Operator | Description | Associativity |
|---|---|---|---|
| 1 | ~ | Bitwise NOT | Right-to-left |
| 2 | << >> >>> | Bit shifts | Left-to-right |
| 3 | & | Bitwise AND | Left-to-right |
| 4 | ^ | Bitwise XOR | Left-to-right |
| 5 | | | Bitwise OR | Left-to-right |
Common pitfall: x & 1 == 0 parses as x & (1 == 0), not (x & 1) == 0. Always parenthesize.
| Type | Bits | Min | Max | Unsigned Max |
|---|---|---|---|---|
| int8_t | 8 | -128 | 127 | 255 (uint8_t) |
| int16_t | 16 | -32,768 | 32,767 | 65,535 (uint16_t) |
| int32_t | 32 | -2,147,483,648 | 2,147,483,647 | 4,294,967,295 |
| int64_t | 64 | −9.22×10¹⁸ | 9.22×10¹⁸ | 1.84×10¹⁹ |
AND, OR, XOR, NOT, shift — enter two numbers and see the result in binary, hex, and decimal instantly.
Open Bitwise Calculator →Operators follow C17/C++20 standards. Ranges follow ISO C <stdint.h>. Last updated August 2026.