THE LANGUAGE UNDER THE ADDRESS
Binary: Read It, Build It, Understand It
Binary is another way to write a number, not a different number. Decimal uses ten digits, 0 through 9. Binary uses only two, 0 and 1. A bit is one binary digit; eight bits make a byte. Each IPv4 octet is one byte, so the same address can be displayed as four decimal numbers or four groups of eight bits.
Position gives a digit its value
In decimal, 205 means 2 hundreds, 0 tens, and 5 ones. Moving left multiplies a place value by ten. In binary, moving left doubles it: 1, 2, 4, 8, 16, 32, 64, 128.
Read an eight-bit row left to right as 128, 64, 32, 16, 8, 4, 2, 1. A 1 includes that position's value; a 0 contributes nothing. The leftmost position is the most significant bit; the rightmost is the least significant bit.
Think: eight labeled switches
Imagine eight switches labeled with those values. Switching 64, 8, 4, and 1 on produces 77. Switching 128 on produces 128 by itself. The switches do not change value; you change which ones contribute.
Keep the zeros in their places. 01000000 is 64, but 00000010 is 2. Both have one active bit; its position makes the difference.
Break it down: binary to decimal
- Align the places. Write
01001101 beneath 128 64 32 16 8 4 2 1. - Keep only the 1s. They select 64, 8, 4, and 1. The other positions contribute 0.
- Add the selected values.
64 + 8 + 4 + 1 = 77. Binary 01001101 and decimal 77 represent the same quantity.
Build it up: decimal to binary
Start with decimal 77 and work from the largest place to the smallest. Ask whether that place fits into the remainder. If yes, write 1 and subtract it. If no, write 0 and keep the remainder.
Build 77 one place at a time| Place | Fits the remainder? | Write | Remainder |
|---|
| 128 | No: 128 > 77 | 0 | 77 |
| 64 | Yes: 77 - 64 | 1 | 13 |
| 32 | No: 32 > 13 | 0 | 13 |
| 16 | No: 16 > 13 | 0 | 13 |
| 8 | Yes: 13 - 8 | 1 | 5 |
| 4 | Yes: 5 - 4 | 1 | 1 |
| 2 | No: 2 > 1 | 0 | 1 |
| 1 | Yes: 1 - 1 | 1 | 0 |
The finished row is 01001101. Check your work by adding its active places back together.
Why 0 through 255?
Eight bits have 2^8 = 256 possible patterns. All off, 00000000, is 0. All on, 11111111, is 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255. Counting from 0 gives 256 values, not 255.
Leading zeros preserve the eight-bit width without changing the value: 101 and 00000101 both mean 5. This module uses unsigned bytes; its leftmost bit is not a minus sign.
Counting and carrying
Binary counts 0, 1, 10, 11, 100, 101.... After 1, that place resets to 0 and carries a 1 into the next place. Binary 10 is decimal 2, not decimal ten.
00000111 = 7
00001000 = 8
11111111 = 255
100000000 = 256 (nine bits)
256 needs a ninth bit, so it cannot fit inside one IPv4 octet. Bit count measures the representation; it does not mean that many hosts.
Connect it to IPv4: 192.168.10.77 is 11000000.10101000.00001010.01001101. A subnet mask is binary too: 11111111.11111111.11111111.11000000 is 255.255.255.192, or /26. A zero in an address is normal; the mask determines whether the whole address is a network, broadcast, or host.
Check your reasoning: what is 10000001, and why?
129: the 128 and 1 places are on. There are two active bits, but the answer is not 2. Always add the place values, not the number of 1s.
Another conversion method: divide by two
Repeatedly divide the decimal number by 2 and record each remainder. For 13: 13 / 2 = 6 remainder 1; 6 / 2 = 3 remainder 0; 3 / 2 = 1 remainder 1; 1 / 2 = 0 remainder 1. Read the remainders bottom to top: 1101. Pad to eight bits: 00001101. Both methods produce the same result; choose the one you can explain confidently.
Practice before adding time pressure
- Explore. Toggle the eight places and watch the sum, or load a decimal value. Step through its conversion, then transfer the byte into the IPv4 visualizer.
- Practice. Choose a direction and range. Build the requested byte or read a byte into decimal. Check your answer and read the reasoning before advancing through ten questions.
- Speedrun. Start a 60-second round. New requests arrive every eight seconds. Select any queued request to solve; the queue holds four. An overflowing request is counted as missed. Pause whenever you need; leaving the tab pauses the round automatically.