Binary Numbers and Decimal-Binary Conversion
Binary numbers are fundamental to digital systems, including computers and networking. Unlike the decimal system (base-10) we use daily, binary (base-2) uses only two digits—0 and 1—to represent all values. Understanding binary counting and conversion between these systems is crucial for grasping how computers process and store data.
Key Points
- Binary system (base-2): Uses only
0and1to represent numbers. - Decimal system (base-10): Uses digits
0to9, with each position representing a power of 10. - Bit: The smallest unit of data in computing, representing a single binary digit (0 or 1).
- Positional notation: The value of a digit depends on its position (e.g., in binary,
101= 5, not 101). - Powers of two: Each binary position corresponds to a power of 2 (1, 2, 4, 8, 16, etc.).
How Binary Counting Works
Binary counting follows the same logic as decimal counting but with a key difference:
- In decimal, you reset to
0and carry over1when reaching9. - In binary, you reset to
0and carry over1when reaching1.
Example:
Decimal: 7 → 8 → 9 → 10
Binary: 0111 → 1000 → 1001 → 1010
Key Insight: Each time a binary number reaches all
1s (e.g.,111), adding1requires a new bit (e.g.,1000).
Conversion Methods
Decimal to Binary
To convert a decimal number to binary:
- Divide the number by
2and record the remainder. - Repeat the division with the quotient until it reaches
0. - The binary number is the remainders read bottom to top.
Example: Convert 13 to binary.
13 ÷ 2 = 6 remainder 1
6 ÷ 2 = 3 remainder 0
3 ÷ 2 = 1 remainder 1
1 ÷ 2 = 0 remainder 1
Reading remainders from bottom to top: 1101₂.
Binary to Decimal
To convert binary to decimal:
- Identify the positions of
1bits (starting from the right, position 0). - Multiply each
1by2ⁿ(wherenis its position). - Sum the results.
Example: Convert 1010₂ to decimal.
1×2³ + 0×2² + 1×2¹ + 0×2⁰ = 8 + 0 + 2 + 0 = 10₁₀
Why Bits Expand
Binary numbers grow by adding bits when the current bit limit is exceeded. Each new bit doubles the maximum representable value.
| Bits | Maximum Value (2ⁿ - 1) | Example |
|---|---|---|
| 1 | 1 | 1 |
| 2 | 3 | 11 |
| 3 | 7 | 111 |
| 4 | 15 | 1111 |
| 5 | 31 | 11111 |
Formula: Maximum value =
2ⁿ - 1, wherenis the number of bits.
Practical Applications
Networking: IPv4 Addresses
- An IPv4 address uses
32 bits, allowing for4,294,967,296unique addresses (2³²). - Example:
192.168.1.1is a 32-bit binary number split into four 8-bit segments (octets).
Memory and Storage
- 1 byte = 8 bits (e.g.,
01001101). - 1 kilobyte (KB) = 1024 bytes (2¹⁰ bytes).
Common Mistakes to Avoid
- Misreading binary positions:
101is5, not101. - Assuming binary is "different": The counting logic is identical to decimal, just with a smaller base.
- Ignoring leading zeros:
0010is the same as10(both = 2). - Confusing bits and bytes: A bit is a single 0/1; a byte is 8 bits.
Visual Reference: Decimal vs. Binary
| Decimal | Binary |
|---|---|
| 0 | 0 |
| 1 | 1 |
| 2 | 10 |
| 3 | 11 |
| 4 | 100 |
| 5 | 101 |
| 6 | 110 |
| 7 | 111 |
| 8 | 1000 |
| 16 | 10000 |
Learn More
- Hexadecimal (base-16): A compact way to represent binary (e.g.,
1A=00011010). - Signed binary numbers: How computers represent negative numbers (e.g., two’s complement).
- Floating-point binary: How decimal fractions are stored in binary (e.g.,
0.1in binary is infinite).
Summary
- Binary is a base-2 system using only
0and1. - Each bit represents a power of 2, and adding bits doubles the maximum value.
- Conversion between decimal and binary relies on division/remainders (decimal → binary) or positional values (binary → decimal).
- Binary is the backbone of computing, networking, and digital logic.