Activity 1.2.2 — The Binary Number System¶
Learning Objectives¶
By the end of this lesson, students will be able to:
- Explain why computers use the binary number system.
- Convert binary numbers to decimal numbers and vice versa.
- Identify common groupings of bits (nibble, byte).
- Understand the relationship between binary and digital logic.
Vocabulary¶
Vocabulary (click to expand)
| Term | Definition |
|---|---|
| Binary | A number system that uses only two digits (0 and 1). Also called base-2. |
| Decimal | The base-10 number system using digits 0-9. |
| Bit | A single binary digit (0 or 1). Short for "binary digit." |
| Byte | A group of 8 bits. |
| Nibble | A group of 4 bits (half a byte). |
| Place Value | The value of a digit based on its position in a number. |
| Weighted Sum | A method of conversion where each digit is multiplied by its place value. |
| ASCII | American Standard Code for Information Interchange—a code that represents text characters as binary numbers. |
Part 1: Understanding Number Systems¶
Our Familiar Decimal System¶
We use the decimal (base-10) number system every day without thinking about it. This system has:
- 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
- Place values: 1, 10, 100, 1000, and so on (powers of 10)
Example: The number 4,739
Place values: 1000 100 10 1
----- ----- ---- ---
Digits: 4 7 3 9
Calculation: (4 x 1000) + (7 x 100) + (3 x 10) + (9 x 1)
= 4000 + 700 + 30 + 9
= 4,739
Why Binary?¶
Computers use the binary (base-2) number system because:
-
Electronic devices have two states: A transistor can be either ON (conducting) or OFF (not conducting).
-
Two states are easy to distinguish: It is easier and more reliable for electronics to detect "high voltage" vs. "low voltage" than to detect many different voltage levels.
-
Noise resistance: With only two states, small voltage fluctuations do not cause errors.
Think of it like a light switch: - OFF = 0 (no voltage, logical FALSE) - ON = 1 (voltage present, logical TRUE)
Part 2: Binary Place Values¶
Binary uses only 0s and 1s, but place values follow powers of 2:
Binary Place Value Table¶
Note: We read place values from right to left, starting at position 0.
Maximum Values¶
| Bits | Number of Values | Maximum Decimal |
|---|---|---|
| 1 bit | 2 (0-1) | 1 |
| 4 bits (1 nibble) | 16 (0-15) | 15 |
| 8 bits (1 byte) | 256 (0-255) | 255 |
| 16 bits | 65,536 (0-65,535) | 65,535 |
Part 3: Counting in Binary¶
Binary Counting Sequence¶
Decimal Binary
-------- -------
0 0
1 1
2 10
3 11
4 100
5 101
6 110
7 111
8 1000
9 1001
10 1010
11 1011
12 1100
13 1101
14 1110
15 1111
Pattern to notice: Each time you add 1 to the rightmost bit (position 0): - If it is 0, it becomes 1 - If it is 1, it becomes 0 and causes a "carry" to the next position to the left
Part 4: Binary to Decimal Conversion¶
To convert binary to decimal, use the weighted sum method.
Method: Weighted Sum¶
Multiply each binary digit by its place value, then add the results.
Worked Example: Convert 11010₂ to Decimal¶
Step 1: Write the place values above each bit
Place values: 16 8 4 2 1
---- ---- ---- ---- ----
Binary digit: 1 1 0 1 0
Step 2: Multiply each digit by its place value
(1 x 16) + (1 x 8) + (0 x 4) + (1 x 2) + (0 x 1)
Step 3: Add the products
16 + 8 + 0 + 2 + 0 = 26
Answer: 11010₂ = 26₁₀
Another Example: Convert 101101₂ to Decimal¶
Place values: 32 16 8 4 2 1
---- ---- ---- ---- ---- ----
Binary digit: 1 0 1 1 0 1
(1 x 32) + (0 x 16) + (1 x 8) + (1 x 4) + (0 x 2) + (1 x 1)
= 32 + 0 + 8 + 4 + 0 + 1
= 45
Answer: 101101₂ = 45₁₀
Part 5: Decimal to Binary Conversion¶
To convert decimal to binary, use the successive division method.
Method: Successive Division by 2¶
- Divide the decimal number by 2
- Write down the remainder (0 or 1)
- Continue dividing each quotient by 2 until you reach 0
- Read the remainders from bottom to top (this is your binary answer)
Worked Example: Convert 45₁₀ to Binary¶
Step 1: Divide by 2 repeatedly, recording remainders
45 ÷ 2 = 22 remainder 1 ↑ Write this 1
22 ÷ 2 = 11 remainder 0 ↑
11 ÷ 2 = 5 remainder 1 ↑
5 ÷ 2 = 2 remainder 1 ↑
2 ÷ 2 = 1 remainder 0 ↑
1 ÷ 2 = 0 remainder 1 ↑ (stop here)
Step 2: Read remainders from bottom to top
Remainders: 1, 0, 1, 1, 0, 1
Answer: 45₁₀ = 101101₂
Another Example: Convert 127₁₀ to Binary¶
127 ÷ 2 = 63 remainder 1
63 ÷ 2 = 31 remainder 1
31 ÷ 2 = 15 remainder 1
15 ÷ 2 = 7 remainder 1
7 ÷ 2 = 3 remainder 1
3 ÷ 2 = 1 remainder 1
1 ÷ 2 = 0 remainder 1
Read bottom to top: 1111111
Check: 1+2+4+8+16+32+64 = 127 ✓
Answer: 127₁₀ = 1111111₂
Key insight: The largest 7-bit binary number (1111111₂) equals 127, which is why 127 is the maximum value in many computing contexts (like the maximum port number in networking).
Part 6: Common Bit Groupings¶
Nibble (4 bits)¶
A nibble is 4 bits, which can represent values from 0 to 15 (16 values).
Byte (8 bits)¶
A byte is 8 bits, which can represent values from 0 to 255 (256 values).
Binary MSB to LSB Decimal Range
------------------ -------------
00000000 0
00000001 1
...
11111111 255
Bytes are the fundamental unit of computer memory. Common terms: - Kilobyte (KB) = 1,024 bytes (2¹⁰) - Megabyte (MB) = 1,024 KB - Gigabyte (GB) = 1,024 MB
Real-World Example¶
The letter "A" in ASCII code:
Binary: 01000001
Decimal: 65
The letter "a" in ASCII code:
Binary: 01100001
Decimal: 97
Summary¶
Quick Reference: Binary Place Values¶
| Position | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|
| Place Value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Conversion Summary¶
| Conversion | Method |
|---|---|
| Binary to Decimal | Multiply each bit by its place value, then sum |
| Decimal to Binary | Divide by 2 repeatedly, read remainders bottom to top |
Bit Groupings¶
| Group | Bits | Decimal Range |
|---|---|---|
| Nibble | 4 | 0-15 |
| Byte | 8 | 0-255 |
Key Reminders¶
- Binary uses only 0s and 1s because computers use transistors with two states (on/off).
- Each binary digit (bit) represents a power of 2 based on its position.
- A byte is 8 bits; a nibble is 4 bits.
- To convert binary to decimal, use weighted sum.
- To convert decimal to binary, use successive division by 2.
Practice Problem 1 — Binary to Decimal¶
Convert 10011011₂ to decimal.
Show Solution
Practice Problem 2 — Decimal to Binary¶
Convert 217₁₀ to binary.
Show Solution
Step 1: Successive division by 2
217 ÷ 2 = 108 remainder 1
108 ÷ 2 = 54 remainder 0
54 ÷ 2 = 27 remainder 0
27 ÷ 2 = 13 remainder 1
13 ÷ 2 = 6 remainder 1
6 ÷ 2 = 3 remainder 0
3 ÷ 2 = 1 remainder 1
1 ÷ 2 = 0 remainder 1
Step 2: Read remainders from bottom to top
11011001
Answer: 217₁₀ = 11011001₂
Check: 128+64+0+16+8+0+0+1 = 217 ✓
Practice Problem 3 — Nibble Maximum¶
What is the maximum decimal value that can be represented with 4 bits? Show your work.
Show Solution
Interactive Quiz — Test Your Understanding¶
Show Explanation
45 = 32 + 8 + 4 + 1 = 101101₂
Show Explanation
11010 = 16 + 8 + 0 + 2 + 0 = 26
Show Explanation
A byte = 8 bits (256 possible values, 0-255). A nibble = 4 bits.
Custom activity — adapted from PLTW Digital Electronics