Comprehensive Guide to Number Systems and Basic Operations
What Number Systems Actually Are
Number systems are just ways of representing quantities. That's it. Nothing mystical about them. The reason you grew up thinking in base-10 (decimal) is because you have ten fingers. If you had eight fingers, you'd probably think in base-8 and this entire article would feel normal to you.
Every number system works the same way: you have digits, a base, and positional values. The base tells you how many unique digits you get before you have to carry over. Understanding this makes everything else click.
The Main Number Systems You Need to Know
Most programming, electronics, and computer science work with four number systems. Here's what they are and where you actually encounter them.
Decimal (Base-10)
What you use every day. Digits 0-9. The number 4,582 breaks down as:
4,582 = (4 × 10³) + (5 × 10²) + (8 × 10¹) + (2 × 10⁰) = 4,000 + 500 + 80 + 2
You already know this intuitively. You just never had to explain it until now.
Binary (Base-2)
Computers think in binary because hardware switches are either on (1) or off (0). Two digits only: 0 and 1.
The binary number 1101 means:
1101₂ = (1 × 2³) + (1 × 2²) + (0 × 2¹) + (1 × 2⁰) = 8 + 4 + 0 + 1 = 13
You'll see this in programming, networking (IP addresses), and anything digital.
Hexadecimal (Base-16)
This looks weird because it uses 16 digits: 0-9, then A-F. A=10, B=11, C=12, D=13, E=14, F=15.
Hex exists because it's a compact way to represent binary. One hex digit = 4 binary digits. That's why color codes in web design use hex: #FF5733 is easier to read than the binary equivalent.
Octal (Base-8)
Uses digits 0-7. Less common now, but you still see it in Unix file permissions (chmod commands) and some legacy systems. Three binary digits fit neatly into one octal digit.
Converting Between Number Systems
This is where most people get lost. Here's the practical stuff you actually need.
Decimal to Binary
Divide by 2, keep the remainders. That's the whole method.
Converting 13 to binary:
- 13 ÷ 2 = 6 remainder 1
- 6 ÷ 2 = 3 remainder 0
- 3 ÷ 2 = 1 remainder 1
- 1 ÷ 2 = 0 remainder 1
Read remainders bottom-to-top: 1101₂
Binary to Decimal
Multiply each bit by its positional value (powers of 2), then add them up. We did this above with 1101. It's straightforward once you see a few examples.
Decimal to Hexadecimal
Divide by 16, keep the remainders. If you get a remainder over 9, convert it to its hex letter (10=A, 11=B, etc.).
Converting 254 to hex:
- 254 ÷ 16 = 15 remainder 14 (E)
- 15 ÷ 16 = 0 remainder 15 (F)
Result: FE₁₆
Binary to Hex (The Useful One)
Group binary digits in sets of four, starting from the right. Convert each group to its hex equivalent.
11010110 becomes:
- 1101 = 13 = D
- 0110 = 6 = 6
Result: D6₁₆
Basic Operations in Different Bases
Addition, subtraction, multiplication, and division work the same way regardless of base. You just carry or borrow at different thresholds.
Binary Addition
Rules:
- 0 + 0 = 0
- 0 + 1 = 1
- 1 + 1 = 10 (write 0, carry 1)
- 1 + 1 + 1 = 11 (write 1, carry 1)
Example: 1011 + 1101
1011 + 1101 ------ 11000
The result is 11000₂ = 24 in decimal. Check: 11 + 13 = 24. Correct.
Binary Multiplication
Same as decimal multiplication, but simpler because you're only multiplying by 0 or 1.
1011
× 101
------
1011
0000
+ 1011
------
110111
Result: 110111₂ = 55. Check: 11 × 5 = 55. Works every time.
Where You'll Actually Use This
Most people never need to manually convert number systems. But knowing the basics helps when debugging, reading documentation, or working with low-level systems.
- Programming: Bitwise operations, masks, hex literals in code
- Networking: IPv6 addresses, MAC addresses, subnet masks
- Electronics: Memory addresses, microcontroller registers
- Web development: Hex color codes (#FF0000 = red)
- Security: Encryption keys, hash values, permissions
Quick Reference: Number System Comparison
| System | Base | Digits | Common Use | Example |
|---|---|---|---|---|
| Decimal | 10 | 0-9 | Everyday math | 42 |
| Binary | 2 | 0-1 | Digital circuits, computing | 101010 |
| Octal | 8 | 0-7 | Unix permissions, legacy systems | 755 |
| Hexadecimal | 16 | 0-9, A-F | Memory addresses, colors, encoding | 0xFFA500 |
Common Mistakes That Waste Time
- Forgetting to pad binary numbers when converting to hex. Always group in fours: 101 becomes 0101, not just 101.
- Mixing up positional values in binary. The rightmost digit is 2⁰, not 2¹.
- Overcomplicating conversions. If you understand the base concept, you can derive the method instead of memorizing formulas.
- Ignoring the context. In programming, 0x10 is hex (16 decimal), not ten.
Getting Started: Practical Exercise
Try this without a calculator:
- Convert the decimal number 178 to binary
- Convert that binary result to hexadecimal
- Verify by converting the hex back to decimal
Solution approach:
- 178 ÷ 2 repeatedly → keep remainders → 10110010₂
- Group 10110010 into fours: 1011 0010 → B 2 → 0xB2
- 0xB2 = (11 × 16) + 2 = 176 + 2 = 178 ✓
Do five more conversions by hand. You'll get it faster than you expect. After that, use tools to check your work until the patterns stick.