Tutorial

Binary to Decimal Conversion

Every IPv4 octet is 8 bits. To convert binary to decimal, write the eight place values 128 64 32 16 8 4 2 1 above the bits and add up wherever there is a 1. That is all subnetting binary really is.

The eight place values

An octet has eight positions, each worth double the one to its right:

Bit position87654321
Value1286432168421

These add up to 255 — the largest value one octet can hold.

Binary → decimal (worked example)

Convert 11000000:

128 64 32 16 8 4 2 1
 1   1  0  0  0 0 0 0
128+64 = 192

So 11000000 = 192 — which is why a /26 mask octet is 192.

Convert 11001000: 128 + 64 + 8 = 200.

Decimal → binary (worked example)

Convert 200: go left to right, subtract each place value if it fits.

200 − 128 = 72   → 1
 72 −  64 =  8   → 1
  8 −  32 <0     → 0
  8 −  16 <0     → 0
  8 −   8 =  0   → 1
  0              → 0 0 0
Result: 11001000

Why it matters for subnetting

Subnet masks are just 1-bits (network) followed by 0-bits (host). Reading a mask in binary tells you instantly how many host bits remain: 11111111.11111111.11111111.11000000 is /26 — 26 ones, 6 host bits, 2^6 − 2 = 62 hosts. Once the place values are automatic, the block-size method becomes pure mental maths.

Frequently asked questions

How do you convert binary to decimal quickly?

Write 128 64 32 16 8 4 2 1 above the eight bits and add the place values wherever there is a 1. For example 11100000 = 128+64+32 = 224.

What is the largest value in one octet?

255 — when all eight bits are 1 (128+64+32+16+8+4+2+1). That is why each part of an IPv4 address ranges from 0 to 255.

Do I need binary for the CCNA?

You need to understand it, but with practice you subnet using the block-size shortcut. Binary is the "why" behind the shortcut.

Why are subnet mask octets only certain numbers?

Because a mask is consecutive 1-bits, only these values can appear: 0, 128, 192, 224, 240, 248, 252, 254, 255.

VS
Vipul Sir — Lead Instructor, Attila Technologies20+ years in Cisco networking. Teaching CCNA, CCNP, CCIE & CyberOps in Ahmedabad since 2004.

Want hands-on training?

Learn this on real Cisco lab devices with placement support at Attila Technologies, Ahmedabad.

Start your networking career with Attila Technologies

Hands-on Cisco training, real lab devices and placement support in Ahmedabad.