Free tech learning for everyone, from basics to pro

Routing & SwitchingNetworking SecurityBeginner

Binary and hexadecimal for network engineers, and building your own subnetting cheat sheet

In short: Computers see addresses as bits. Each bit in an octet is worth 128, 64, 32, 16, 8, 4, 2 or 1, and adding them gives the decimal value. Hexadecimal groups four bits into one digit from 0 to F, which is why MAC and IPv6 addresses use it. A short cheat sheet of bit values, masks and block sizes, written from memory, makes subnetting fast and reliable.

Why binary matters

IPv4 addresses are 32 bits, shown as four decimal octets for our convenience. Subnet masks, prefix lengths, wildcard masks and route summaries all work on the bits underneath. Once you can see an octet as eight bits, subnetting stops being a set of rules to memorise and becomes simple arithmetic. If you want the basics of addressing first, see IPv4 addressing.

Binary to decimal and back

Bit values in one octet128bit 164bit 232bit 316bit 48bit 54bit 62bit 71bit 8
Figure 1. Each bit in an octet is worth double the one to its right. Add the values of the bits that are 1 to get the decimal number.

Binary to decimal: write the bit values above the bits and add the ones that are 1. For 11000000, that is 128 + 64 = 192. For 10101000, it is 128 + 32 + 8 = 168.

Decimal to binary: go from left to right. If the number is at least the bit value, write 1 and subtract; otherwise write 0. For 172: 172 is at least 128 (1, leaves 44), less than 64 (0), at least 32 (1, leaves 12), less than 16 (0), at least 8 (1, leaves 4), at least 4 (1, leaves 0), then 0 and 0. Result: 10101100.

Two quick checks: an octet of all ones is 255, and the only values a subnet mask octet can take are 0, 128, 192, 224, 240, 248, 252, 254 and 255, because mask bits are always ones followed by zeros.

Hexadecimal

Hexadecimal (base 16) uses the digits 0 to 9 and the letters A to F for 10 to 15. Each hex digit stands for exactly four bits (a nibble), so two hex digits make one byte. That is why MAC addresses (48 bits, 12 hex digits) and IPv6 addresses (128 bits, 32 hex digits) are written in hex.

DecimalBinaryHexDecimalBinaryHex
000000810008
100011910019
200102101010A
300113111011B
401004121100C
501015131101D
601106141110E
701117151111F

To convert a byte, split it into two nibbles: 192 is 1100 0000, which is C0. To go from hex to decimal, multiply the left digit by 16 and add the right: 0xA8 is 10 × 16 + 8 = 168. Practise with the IP converter and hex tool.

Writing your own cheat sheet

Many students write a small table on scrap paper at the start of an exam or lab. You only need to remember the pattern; the rest follows from doubling and halving.

Prefix (last octet)Mask octetBlock sizeUsable hosts
/25128128126
/261926462
/272243230
/282401614
/2924886
/3025242
/3125422 (point-to-point links only)
  1. Write the bit values 128 to 1 across the top.
  2. Under them, write the running totals 128, 192, 224, 240, 248, 252, 254, 255: these are the mask values.
  3. Under those, write the block sizes, which equal the bit values: 128, 64, 32 and so on.
  4. Repeat the pattern for the third octet (/17 to /24) and second octet (/9 to /16): only the octet changes.
  5. To subnet, find the block size, count up in blocks to find the network, and the address just before the next block is the broadcast.

For example, 10.4.77.130/27: block size 32, so networks start at .0, .32, .64, .96, .128, .160. The host is in 10.4.77.128/27, the broadcast is .159, and usable hosts are .129 to .158. Speed tips are in subnetting in your head, and you can check answers with the subnet calculator.

Real-world example: a new IT technician at a council depot was asked over the phone whether 172.20.14.200/26 and 172.20.14.180/26 were in the same subnet. With no calculator at hand, she wrote 192 and a block size of 64 on a notepad: networks at .128 and .192. The first address was in .192/26 and the second in .128/26, so they needed a router between them, which explained why the new label printer could not be found by the depot PC.

Practice

Convert 224 to binary and hex.
Binary 11100000 (128 + 64 + 32), hex E0.
How many bits does one hexadecimal digit represent?
Four bits, called a nibble.
Which subnet does 192.168.5.77/28 belong to?
Block size 16: 192.168.5.64/28, broadcast 192.168.5.79, usable .65 to .78.

Key takeaways

  • Each octet bit is worth 128, 64, 32, 16, 8, 4, 2 or 1.
  • Mask octets can only be 0, 128, 192, 224, 240, 248, 252, 254 or 255.
  • One hex digit is four bits; two hex digits make a byte.
  • Block size equals the value of the last mask bit and drives quick subnetting.
  • A cheat sheet built from doubling and halving can be written from memory in a minute.
Tracks your learning on this device only. See your progress on the learning paths.

About the author

Mohamed Fayas

Founder of FM TecHub. CCNA certified, with a BTEC HND in Network Engineering, and BEng (Hons) in Computer Networking and Cloud Security. He writes practical, plain-English guides on networking, security and cloud.

More about the author

Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.

Stay up to date by email

New notes, tools and security news from FM TecHub, explained simply. Free.

We only use your email to send these updates. See our privacy policy.