Lesson 34: Binary Review for Networking
Networking, especially IP addressing and subnetting, is based entirely on binary mathematics. You must be comfortable with converting between decimal and binary.
The Power of Two
Binary uses only two digits (0 and 1). In an 8-bit octet, each position has a specific weighted value, which is a power of 2:
| Position | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | Total = 255 |
|---|---|---|---|---|---|---|---|---|---|
| Value | 2^7 | 2^6 | 2^5 | 2^4 | 2^3 | 2^2 | 2^1 | 2^0 |
Converting Decimal to Binary
To convert a decimal number (like 172) to binary, find the largest weight that fits, subtract it, and repeat.
Example: Convert 172 to Binary
- Is 172 >= 128? Yes (1). Remaining: 172 - 128 = 44.
- Is 44 >= 64? No (0).
- Is 44 >= 32? Yes (1). Remaining: 44 - 32 = 12.
- Is 12 >= 16? No (0).
- Is 12 >= 8? Yes (1). Remaining: 12 - 8 = 4.
- Is 4 >= 4? Yes (1). Remaining: 4 - 4 = 0.
- Is 0 >= 2? No (0).
- Is 0 >= 1? No (0).
Result: 10101100
Converting Binary to Decimal
Multiply each binary digit by its weighted position value and sum the results.
Example: Convert 11000000 to Decimal
(1 * 128) + (1 * 64) + (0 * 32) + (0 * 16) + (0 * 8) + (0 * 4) + (0 * 2) + (0 * 1) = 128 + 64 = 192
Practice: Before attempting subnetting, ensure you can quickly convert any decimal number from 0-255 into 8-bit binary.