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
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.
| Decimal | Binary | Hex | Decimal | Binary | Hex |
|---|---|---|---|---|---|
| 0 | 0000 | 0 | 8 | 1000 | 8 |
| 1 | 0001 | 1 | 9 | 1001 | 9 |
| 2 | 0010 | 2 | 10 | 1010 | A |
| 3 | 0011 | 3 | 11 | 1011 | B |
| 4 | 0100 | 4 | 12 | 1100 | C |
| 5 | 0101 | 5 | 13 | 1101 | D |
| 6 | 0110 | 6 | 14 | 1110 | E |
| 7 | 0111 | 7 | 15 | 1111 | F |
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 octet | Block size | Usable hosts |
|---|---|---|---|
| /25 | 128 | 128 | 126 |
| /26 | 192 | 64 | 62 |
| /27 | 224 | 32 | 30 |
| /28 | 240 | 16 | 14 |
| /29 | 248 | 8 | 6 |
| /30 | 252 | 4 | 2 |
| /31 | 254 | 2 | 2 (point-to-point links only) |
- Write the bit values 128 to 1 across the top.
- Under them, write the running totals 128, 192, 224, 240, 248, 252, 254, 255: these are the mask values.
- Under those, write the block sizes, which equal the bit values: 128, 64, 32 and so on.
- Repeat the pattern for the third octet (/17 to /24) and second octet (/9 to /16): only the octet changes.
- 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.
How many bits does one hexadecimal digit represent?
Which subnet does 192.168.5.77/28 belong to?
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.
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.