If you are studying for a networking certification (like the CCNA) or just starting to learn about IT, you’ve probably encountered a scary-looking string of 1s and 0s.
Computers love binary, but humans prefer readable numbers. That is why IPv4 addresses are written in "dotted decimal" format—like 192.168.1.1.
But how do we get from a machine-friendly binary string to a human-friendly IP address? Let’s break down the math using a simple trick.
The Basics: The 32-Bit Address
An IPv4 address is a 32-bit number. To make it readable, we chop it into four equal chunks (called octets) and convert each chunk into a regular decimal number.
Let's use this binary address as an example:
11001011 . 00000000 . 01110001 . 11010011
The Magic Number Trick
To convert an 8-bit chunk into a decimal, you need to know the "place values" of binary. Just like regular math uses ones, tens, and hundreds, binary uses powers of 2.
Memorize this sequence going from left to right:
128 - 64 - 32 - 16 - 8 - 4 - 2 - 1
Whenever you see a 1 in the binary string, you add the corresponding magic number. Whenever you see a 0, you ignore it. Let's test it out on the four chunks!
Chunk 1: 11001011
Line up the binary with the magic numbers:
- 1 = Keep 128
- 1 = Keep 64
- 0 = Ignore
- 0 = Ignore
- 1 = Keep 8
- 0 = Ignore
- 1 = Keep 2
- 1 = Keep 1
The Math: 128 + 64 + 8 + 2 + 1 = 203
Chunk 2: 00000000
All zeros? You don't have to do any math. The answer is 0.
Chunk 3: 01110001
- 0 = Ignore
- 1 = Keep 64
- 1 = Keep 32
- 1 = Keep 16
- 0 = Ignore
- 0 = Ignore
- 0 = Ignore
- 1 = Keep 1
The Math: 64 + 32 + 16 + 1 = 113
Chunk 4: 11010011
- 1 = Keep 128
- 1 = Keep 64
- 0 = Ignore
- 1 = Keep 16
- 0 = Ignore
- 0 = Ignore
- 1 = Keep 2
- 1 = Keep 1
The Math: 128 + 64 + 16 + 2 + 1 = 211
Putting it Together
Now, all you have to do is take your four answers and put dots between them:
203.0.113.211
And just like that, you have converted binary into a dotted decimal IP address!
Top comments (0)