Binary Numbers and Decimal-Binary Conversion
Computers and digital systems rely on binary numbers—a base-2 system using only 0 and 1—to process and store data. Unlike the familiar decimal (base-10) system, binary simplifies hardware design by representing all values with two states. Mastering binary counting and conversion between decimal and binary is essential for understanding computing fundamentals, networking, and digital logic.
Key Concepts
Binary vs. Decimal Systems
- Binary (base-2): Uses only
0and1. Each digit represents a power of 2. - Decimal (base-10): Uses digits
0to9. Each position represents a power of 10. - Bit: The smallest unit of data in computing, representing a single binary digit (
0or1). - Positional notation: The value of a digit depends on its position (e.g., binary
101= decimal5).
Key Insight: Binary and decimal counting follow the same logic—reset to
0and carry over1when the base limit is reached.
How Binary Counting Works
Binary counting increments like decimal but resets after 1 instead of 9. Each new bit doubles the maximum representable value.
Example: Counting from 7 to 10
Decimal: 7 → 8 → 9 → 10
Binary: 0111 → 1000 → 1001 → 1010
Note: Adding
1to111(7) requires a new bit:1000(8).
Conversion Methods
Decimal to Binary
- Divide the decimal number by
2and record the remainder. - Repeat with the quotient until it reaches
0. - Read the remainders bottom to top to get the binary number.
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
Result: 1101₂
Binary to Decimal
- Identify the positions of
1bits (starting from the right at position0). - 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₁₀
Bit Growth and Maximum Values
Each additional bit doubles the maximum representable value. The formula for n bits is:
Maximum value = 2ⁿ - 1
| Bits | Maximum Value (2ⁿ - 1) | Example Binary |
|---|---|---|
| 1 | 1 | 1 |
| 2 | 3 | 11 |
| 3 | 7 | 111 |
| 4 | 15 | 1111 |
| 5 | 31 | 11111 |
Practical Applications
Networking: IPv4 Addresses
- IPv4 uses 32 bits, enabling
4,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 (e.g.,
101is5, not101). - Ignoring leading zeros (e.g.,
0010=10=2). - Confusing bits (single
0/1) with bytes (8 bits). - Assuming binary counting is "different"—it follows the same logic as decimal, just with a smaller base.
Decimal vs. Binary Reference Table
| 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 representation of binary (e.g.,
1A=00011010). - Signed binary numbers: Two’s complement for negative values.
- Floating-point binary: How decimal fractions (e.g.,
0.1) are stored in binary.
Summary
- Binary is a base-2 system using
0and1to represent all values. - Each bit corresponds to a power of 2, and adding bits doubles the maximum value.
- Convert decimal to binary via division/remainders and binary to decimal via positional values.
- Binary underpins computing, networking, and digital logic (e.g., IPv4 addresses, memory storage).