CS Fundamentals
Introduction to number systems used in computing — decimal, binary, octal, and hexadecimal. Learn why computers use different number bases.
Introduction
Humans count in base-10 (decimal) because we have 10 fingers. Computers count in base-2 (binary) because their electronic circuits have only two states: on and off. But binary numbers get very long, so programmers also use base-8 (octal) and base-16 (hexadecimal) as convenient shorthands. Understanding these number systems is fundamental to understanding how computers store and process all data.
What Is a Number System?
A number system is a way of representing numbers using a specific set of symbols (digits) and rules. Each system has a base (or radix) that determines how many unique digits it uses and how place values work.
The Four Number Systems in Computing
Decimal (Base-10)
- Digits used: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
- Why base-10: Humans have 10 fingers (the word "digit" literally means "finger")
- Place values: ...1000s, 100s, 10s, 1s (powers of 10)
- Example: 425 = 4×100 + 2×10 + 5×1
This is the system you use every day. Nothing new here — but understanding place values helps with other bases.
Binary (Base-2)
- Digits used: 0, 1 (called "bits")
- Why base-2: Computers use electronic switches that are either ON (1) or OFF (0)
- Place values: ...16s, 8s, 4s, 2s, 1s (powers of 2)
- Example: 1101₂ = 1×8 + 1×4 + 0×2 + 1×1 = 13 in decimal
Octal (Base-8)
- Digits used: 0, 1, 2, 3, 4, 5, 6, 7
- Why base-8: Each octal digit represents exactly 3 binary digits — compact way to write binary
- Place values: ...512s, 64s, 8s, 1s (powers of 8)
- Example: 37₈ = 3×8 + 7×1 = 31 in decimal
Hexadecimal (Base-16)
- Digits used: 0-9 and A, B, C, D, E, F (A=10, B=11, C=12, D=13, E=14, F=15)
- Why base-16: Each hex digit represents exactly 4 binary digits — very compact
- Place values: ...4096s, 256s, 16s, 1s (powers of 16)
- Example: 2F₁₆ = 2×16 + 15×1 = 47 in decimal
Why Computers Use Binary
Computers use binary because their hardware is built from billions of tiny transistors that act as switches — each can only be in one of two states:
| State | Meaning | Binary |
|---|---|---|
| Switch ON | Current flowing | 1 |
| Switch OFF | No current | 0 |
It's much easier to build reliable electronics with two states than ten. Imagine trying to distinguish between ten different voltage levels precisely — noise and interference would cause constant errors. But distinguishing between "voltage present" and "no voltage" is simple and reliable.
Why Programmers Use Hexadecimal
Binary is great for computers but terrible for humans. Consider this memory address:
- Binary:
1111111111111111101111111111110(31 digits!) - Hexadecimal:
7FFFFFFE(8 digits) - Both represent the same number
Hexadecimal is compact and directly maps to binary (each hex digit = 4 bits), making it the preferred representation for programmers when they need to work with binary data.
Common uses of hex:
- Memory addresses:
0x7FFF8000 - Colors in web design:
#FF5733(red=FF, green=57, blue=33) - MAC addresses:
00:1A:2B:3C:4D:5E - Error codes:
0x80070005
Converting Between Systems
Decimal to Binary (Repeated Division)
Divide by 2 repeatedly, collect remainders bottom-to-top:
25 ÷ 2 = 12 remainder 1 12 ÷ 2 = 6 remainder 0 6 ÷ 2 = 3 remainder 0 3 ÷ 2 = 1 remainder 1 1 ÷ 2 = 0 remainder 1
Reading remainders bottom-to-top: 25₁₀ = 11001₂
Binary to Decimal (Place Values)
Multiply each digit by its place value and add:
11001₂ = 1×16 + 1×8 + 0×4 + 0×2 + 1×1 = 16+8+0+0+1 = 25₁₀
Binary to Hexadecimal (Group by 4)
Group binary digits in sets of 4 from right to left:
1101 0110₂ = D6₁₆ (1101=D, 0110=6)
Hexadecimal to Binary (Expand each digit)
Replace each hex digit with its 4-bit binary equivalent:
A3₁₆ = 1010 0011₂ (A=1010, 3=0011)
Key Takeaways
- Decimal (base-10) is for humans; binary (base-2) is for computers
- Octal (base-8) and hexadecimal (base-16) are compact representations of binary
- Computers use binary because electronic switches have only two states (on/off)
- Hexadecimal is widely used in programming for colors, memory addresses, and debugging
- Converting between systems uses repeated division (decimal→binary) or grouping (binary↔hex)
- Every number can be represented in any base — the value is the same, only the representation differs
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Number Systems.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Computer Fundamentals topic.
Search Terms
computer-fundamentals, computer fundamentals, computer, fundamentals, data, representation, number, systems
Related Computer Fundamentals Topics