Binary Arithmetic Operations
| Operation | Description | Example |
|---|---|---|
| ADD | Binary addition with carry | 1010 + 0110 = 10000 |
| SUB | Binary subtraction with borrow | 1010 − 0110 = 0100 |
| AND | 1 only when both bits are 1 | 1010 AND 0110 = 0010 |
| OR | 1 when at least one bit is 1 | 1010 OR 0110 = 1110 |
| XOR | 1 when bits are different | 1010 XOR 0110 = 1100 |
| NOT | Flips all bits (bitwise complement) | NOT 1010 = …11110101 |
Bitwise Truth Table
| A | B | AND | OR | XOR |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 |
Real-World Uses of Bitwise Operations
- AND: Masking — extracting specific bits. Setting flags in operating systems. Checking if a number is even: (n AND 1) = 0 if even.
- OR: Setting specific bits. Combining flags.
- XOR: Toggling bits. Encryption (simple XOR cipher). Swap two numbers without a temp variable: a=a XOR b; b=a XOR b; a=a XOR b
- NOT: Creating bitmask complements. Two's complement for negative numbers.
🔌 Perform binary operations — enter binary numbers and select operation
Open Binary Calculator →binary arithmetic calculatorbinary additionbinary AND OR XORbitwise calculatorbinary NOTbinary operationsbinary math calculatorcomputer science calculator