subbing/24
Subbing › Guides › Binary and hex for networking

Binary and hex for networking

The place values, the eight mask bytes, hex digits and the conversions that make subnetting and IPv6 fast.

Networking only ever needs one byte at a time. Learn the byte and the rest follows.

Place values

From left to right a byte's bits are worth 128, 64, 32, 16, 8, 4, 2, 1. To convert decimal to binary, subtract the largest value that fits and mark a 1: 200 = 128 + 64 + 8, so 11001000.

The mask bytes

Ones12345678
Value128192224240248252254255

Every subnet mask octet is one of these. Seeing 248 and knowing it is five ones (and block size 8) is the whole trick.

Hex

One hex digit is four bits: 0 to 9 then a to f for 10 to 15. A byte is two hex digits; the left one counts sixteens. 0xC0 is 12 × 16 + 0 = 192. To go from hex to binary, convert each digit to four bits and join them: c = 1100, 0 = 0000, so 11000000.

How many values fit in n bits

2n. Eight bits hold 256 values, which is why octets run 0 to 255, and why a /24 has 256 addresses.

Start drilling binary & hexGet the Android app

More on this topic: Binary and hex practice, with sample questions and the full list of question types.