How to do binary arithmetic
- Enter two binary numbers (0s and 1s).
- Choose the operation: +, −, ×, ÷, AND, OR or XOR.
- Read the result in binary, with decimal, octal and hex alongside.
Binary place values
| Bit | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| 1011 0101 | 1 | 0 | 1 | 1 | 0 | 1 | 0 | 1 |
That byte is 128 + 32 + 16 + 4 + 1 = 181. Each place is worth twice the one to its right.
Binary arithmetic by hand
Subtraction borrows 2 instead of 10: 10 − 1 = 1 in binary. Multiplication is shifting and adding, because each digit is 0 or 1: 101 × 11 is 101 + 1010 = 1111 (5 × 3 = 15). That simplicity is why computers work in binary.
Bitwise operations
AND keeps bits that are set in both numbers, which is how a mask picks out part of a value: 1101 AND 0100 = 0100 tests whether the third bit is on. OR sets bits, and XOR flips them; XOR-ing twice with the same value gets the original back.