Bitwise Calculator
Perform bitwise operations: AND, OR, XOR, NOT, NAND, NOR - or evaluate full expressions like 0xFF & 0b1010 << 2.
Expression Mode
Type a full expression with C-style precedence - mix hex, binary, octal, and decimal: 0xFF & 0b1010 << 2, ~5 | (1 << 4)
Bitwise Truth Table
| A | B | AND | OR | XOR | NAND | NOR |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 |
Code Examples
const a = 0b1010; // 10
const b = 0b1100; // 12
a & b; // AND: 0b1000 (8)
a | b; // OR: 0b1110 (14)
a ^ b; // XOR: 0b0110 (6)
~a; // NOT: -11 (inverts all bits)Frequently Asked Questions
What are bitwise operations used for?
Bitwise operations are used for: setting/clearing flags, permission systems, graphics programming, cryptography, network protocols, and optimized arithmetic.
What's the difference between AND and OR?
AND (&) returns 1 only when both bits are 1. OR (|) returns 1 when either bit is 1. AND is used to check/clear bits, OR is used to set bits.
What is XOR used for?
XOR (^) returns 1 when bits differ. Common uses: toggling bits, swapping values without temp variable, simple encryption, checksum calculations.
Related Tools
Binary Calculator
Add, subtract, multiply, and divide binary numbers with decimal and hex output.
Bit Shift Calculator
Calculate left and right bit shifts with visual representation.
Bitmask Generator & Register Workbench
Build, paste and visualize bitmasks at 8, 16, 32 or 64 bits - then generate the set, clear, toggle and field-extract code for them.
Two's Complement Calculator
Calculate two's complement representation for signed integers.
This tool runs entirely in your browser - nothing you enter is uploaded or stored.