Powers of 2 Reference
| Power | Decimal | Binary | Hex | Use |
|---|---|---|---|---|
| 2⁰ | 1 | 1 | 1 | — |
| 2⁴ | 16 | 10000 | 10 | Hex digit |
| 2⁸ | 256 | 100000000 | 100 | 1 Byte max+1 |
| 2¹⁰ | 1,024 | 10000000000 | 400 | 1 KB |
| 2¹⁶ | 65,536 | — | 10000 | Port range |
| 2²⁰ | 1,048,576 | — | 100000 | 1 MB |
| 2³² | 4,294,967,296 | — | — | IPv4 addresses |
How Binary Works
Binary uses two digits — 0 and 1 — where each position is a power of 2. The rightmost bit is 2⁰ (value 1), moving left: 2¹ (2), 2² (4), 2³ (8). Example: 1010 = 0×1 + 1×2 + 0×4 + 1×8 = 10 in decimal.
Bitwise Operations
AND (&): both bits must be 1 to return 1. OR (|): at least one bit is 1. XOR (^): bits must differ to return 1. These are CPU-level primitives used in flags, masks, and cryptographic algorithms.