This lesson includes an expert video walkthrough — purchase once for a full year of unlimited replays to master every key point 🎬
Number Base Conversion
Knowledge Summary
Common Number Systems
| Base | Radix | Digit Range | Prefix |
|---|---|---|---|
| Binary | 2 | 0-1 | 0b |
| Octal | 8 | 0-7 | 0 |
| Decimal | 10 | 0-9 | None |
| Hexadecimal | 16 | 0-9, A-F | 0x |
Converting an Arbitrary Base to Decimal
Positional expansion method: multiply each digit by the weight of its position, then sum them up.
Example: (1011)₂ = 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 8 + 0 + 2 + 1 = 11
Example: (2A)₁₆ = 2×16¹ + 10×16⁰ = 32 + 10 = 42
Converting Decimal to an Arbitrary Base
Repeated division method: keep dividing by the base and write the remainders from bottom to top.
Example: convert 42 to binary
142 ÷ 2 = 21 ... 0
221 ÷ 2 = 10 ... 1
310 ÷ 2 = 5 ... 0
4 5 ÷ 2 = 2 ... 1
5 2 ÷ 2 = 1 ... 0
6 1 ÷ 2 = 0 ... 1Result: (101010)₂
Binary <-> Octal / Hexadecimal
- Binary to octal: every 3 binary digits correspond to 1 octal digit
- Binary to hexadecimal: every 4 binary digits correspond to 1 hexadecimal digit
Frequently Tested Calculations
- Binary addition and subtraction
- Fast conversion between different number systems
- Representations of a given number in different bases