Bitwise Calculator
Perform bitwise operations: AND, OR, XOR, NOT, NAND, NOR.
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
Generate bitmasks by selecting bit positions visually.
Two's Complement Calculator
Calculate two's complement representation for signed integers.