Base 2 Number System- Understanding Binary Code
What Binary Actually Is
Binary is a number system with only two digits: 0 and 1. That's it. No 2s, no 3s, nothing fancy. Every binary digit (called a bit) is either off (0) or on (1).
Your computer doesn't understand letters, images, or videos. It only understands these two states. Every email you've sent, photo you've taken, and video you've watched comes down to millions of zeros and ones processed by silicon.
Why Computers Use Binary (Not Decimal)
Hardware is binary by nature. A transistor is either conducting electricity or it isn't. A capacitor either holds charge or it doesn't. These physical on/off states map perfectly to 0s and 1s.
Decimal would require detecting ten different voltage levels. That's unreliable and expensive to build. Binary gives you noise margins that make modern computing possible. Two states are easy to distinguish, even with electrical interference.
How Binary Numbers Work
Each position in a binary number represents a power of 2, reading right to left:
- Position 0: 2⁰ = 1
- Position 1: 2¹ = 2
- Position 2: 2² = 4
- Position 3: 2³ = 8
- Position 4: 2⁴ = 16
- Position 5: 2⁵ = 32
Compare this to decimal where each position is a power of 10:
- Position 0: 10⁰ = 1
- Position 1: 10¹ = 10
- Position 2: 10² = 100
Reading Binary: Step by Step
Let's convert 11010 to decimal.
Write out the place values from right to left:
1 1 0 1 0
16 8 4 2 1
Add up where there's a 1:
16 + 8 + 2 = 26
That's it. Binary 11010 equals decimal 26.
Another Example: 101101
1 0 1 1 0 1
32 16 8 4 2 1
32 + 8 + 4 + 1 = 45
Converting Decimal to Binary
Use the division method:
- Divide the number by 2
- Write down the remainder (0 or 1)
- Repeat with the quotient until you reach 0
- Read remainders bottom to top
Let's convert 23 to binary:
23 ÷ 2 = 11 remainder 1
11 ÷ 2 = 5 remainder 1
5 ÷ 2 = 2 remainder 1
2 ÷ 2 = 1 remainder 0
1 ÷ 2 = 0 remainder 1
Read bottom to top: 10111
Check: 16 + 4 + 2 + 1 = 23 ✓
Binary in the Real World
Eight bits make a byte. A byte can represent values from 0 to 255. That's why old computers maxed out at 256 colors, 256 characters, etc.
- 1 kilobyte (KB) = 1,024 bytes
- 1 megabyte (MB) = 1,024 KB
- 1 gigabyte (GB) = 1,024 MB
Text characters are mapped to binary using encoding standards. ASCII uses 7 bits per character. 'A' is 65 in decimal, or 01000001 in binary. 'a' is 97, or 01100001.
Quick Reference: Common Binary Values
| Binary | Decimal | Notes |
|---|---|---|
| 00000000 | 0 | All off |
| 00000001 | 1 | Least significant bit |
| 00001111 | 15 | Lower nibble on |
| 11111111 | 255 | Max byte value |
| 10000000 | 128 | Most significant bit set |
| 10101010 | 170 | Alternating pattern |
Getting Started: Practice Exercises
Try converting these without looking at the answers first:
Exercise 1: What is 0110 in decimal?
Answer: 6 (4 + 2)
Exercise 2: What is 100100 in decimal?
Answer: 36 (32 + 4)
Exercise 3: Convert 47 to binary.
Answer: 101111
Exercise 4: What decimal value does 11111111 represent?
Answer: 255
Once you can do these conversions quickly, you've got the basics down. The next step is understanding how computers use these patterns for logic operations, but that's a separate topic.