Table of Contents
- Introduction to Number Systems
- Binary (Base-2)
- Denary/Decimal (Base-10)
- Hexadecimal (Base-16)
- Conversions Between Number Systems
- Why Do Programmers Use Hexadecimal?
- Summary & Key Takeaways
1. Introduction to Number Systems
Numbers can be represented in different bases (or radix). The most common ones in computing are:
System | Base | Digits Used | Example |
---|---|---|---|
Binary | 2 | 0, 1 | 1010 |
Denary | 10 | 0-9 | 42 |
Hexadecimal | 16 | 0-9, A-F | 2F |
- Binary: Used by computers (everything is
0
s and1
s). - Denary: Humans use this daily (standard counting).
- Hexadecimal: A compact way to represent binary for programmers.
2. Binary (Base-2)
- Only two digits:
0
and1
. - Each digit is called a bit (8 bits = 1 byte).
- Used in computers because transistors (hardware) operate in two states: ON (1) and OFF (0).
Binary to Denary Conversion
Each binary digit represents a power of 2, starting from the right (LSB → MSB).
Example: 1011
in binary → Denary?
Bit Position | 3 | 2 | 1 | 0 |
---|---|---|---|---|
Binary Digit | 1 | 0 | 1 | 1 |
Calculation | 1×2³ | 0×2² | 1×2¹ | 1×2⁰ |
Value | 8 | 0 | 2 | 1 |
Total = 8 + 0 + 2 + 1 = 11
(Denary)
3. Denary/Decimal (Base-10)
- Uses digits
0-9
. - How humans naturally count.
Denary to Binary Conversion
Divide the number by 2 repeatedly and note remainders.
Example: Convert 13
to binary.
Division | Quotient | Remainder |
---|---|---|
13 ÷ 2 | 6 | 1 (LSB) |
6 ÷ 2 | 3 | 0 |
3 ÷ 2 | 1 | 1 |
1 ÷ 2 | 0 | 1 (MSB) |
Read remainders from bottom-up → 1101
(Binary)
4. Hexadecimal (Base-16)
- Uses digits
0-9
and lettersA-F
(whereA=10
,B=11
, …,F=15
). - Shorter representation of binary (1 hex digit = 4 binary digits).
Hexadecimal to Denary Conversion
Each hex digit represents a power of 16.
Example: 2F
in hex → Denary?
Digit | Position | Calculation | Value |
---|---|---|---|
2 | 1 | 2 × 16¹ | 32 |
F (15) | 0 | 15 × 16⁰ | 15 |
Total = 32 + 15 = 47
(Denary)
Binary to Hexadecimal
Group binary digits into 4-bit nibbles and convert each to hex.
Example: 11010110
→ Hex?
- Split into nibbles:
1101
0110
- Convert each:
1101
=13
→D
0110
=6
→6
Result: D6
(Hex)
5. Conversions Between Number Systems
Quick Conversion Table
Denary | Binary (8-bit) | Hexadecimal |
---|---|---|
0 | 00000000 | 0 |
5 | 00000101 | 5 |
10 | 00001010 | A |
15 | 00001111 | F |
255 | 11111111 | FF |
6. Why Do Programmers Use Hexadecimal?
1. Compact Representation
- Writing long binary strings is tedious.
- Example:
- Binary:
1101001110101101
- Hex:
D3AD
(Much shorter!)
- Binary:
2. Easier to Read & Debug
- Memory addresses, color codes (
#FF5733
), and binary data are often represented in hex.
3. Direct Mapping to Binary
- Each hex digit = 4 binary digits (nibble).
- Makes binary manipulation easier.
4. Historical Use in Computing
- Early computers used hex for simplicity in low-level programming.
7. Summary & Key Takeaways
✔ Binary (Base-2) → Computers understand it.
✔ Denary (Base-10) → Humans use it daily.
✔ Hexadecimal (Base-16) → Shorthand for binary, used in programming.
Conversion Methods
From → To | Method |
---|---|
Binary → Denary | Sum of powers of 2. |
Denary → Binary | Divide by 2, track remainders. |
Binary → Hex | Group into 4-bit nibbles. |
Hex → Denary | Sum of powers of 16. |
Why Hex?
- Shorter than binary.
- Easier to read & debug.
- Directly maps to binary (1 hex digit = 4 bits).
Final Thought
Hexadecimal is like a “compressed binary”—it makes life easier for programmers while keeping close ties to how computers work.
🚀 Now you can convert and understand these number systems like a pro!
(Need a cheat sheet? Here’s a quick reference table below!)
Quick Reference Table
System | Base | Digits | Example |
---|---|---|---|
Binary | 2 | 0,1 | 1010 |
Denary | 10 | 0-9 | 42 |
Hex | 16 | 0-9, A-F | 2F |