Binary and hexadecimal for network engineers: conversions you will use every day
In short: Computers store everything as bits, so networking is full of binary and hexadecimal. Binary uses place values 128, 64, 32, 16, 8, 4, 2, 1 for each octet; hexadecimal packs four bits into one digit from 0 to F. With a few patterns learnt by heart you can read masks, MAC addresses and IPv6 addresses quickly.
Why network engineers need number systems
Routers, switches and hosts work in bits, ones and zeros. People find long strings of bits hard to read, so we write them in more compact forms: IPv4 addresses and masks in decimal (base 10), and MAC addresses, IPv6 addresses and packet captures in hexadecimal (base 16). Subnetting, wildcard masks, EUI-64 and reading a capture all become easy once you can move between the three systems without thinking too hard.
A few words first: a bit is a single 0 or 1; a nibble is 4 bits; a byte is 8 bits. In IPv4, each 8-bit part of an address is called an octet.
Binary: place values
In decimal, each position is worth ten times the one to its right (ones, tens, hundreds). In binary, each position is worth two times the one to its right. For one octet the place values are:
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 1 | 1 | 0 | 0 | 1 | 0 | 0 | 1 |
Binary to decimal: add the place values where there is a 1. The row above is 128 + 64 + 8 + 1 = 201.
Decimal to binary: work from the left. If the place value fits into what is left, write 1 and subtract it; otherwise write 0. For 90: 128 does not fit (0); 64 fits, 26 left (1); 32 does not fit (0); 16 fits, 10 left (1); 8 fits, 2 left (1); 4 does not fit (0); 2 fits, 0 left (1); 1 does not fit (0). So 90 = 01011010.
An octet of all ones is 255, and n bits can hold 2n different values. That is why 8 host bits give 256 addresses.
Patterns worth memorising
Subnet masks are always a run of ones followed by zeros, so only nine values can ever appear in a mask octet. Knowing them saves time in every subnetting question.
| Ones in the octet | Binary | Decimal |
|---|---|---|
| 0 | 00000000 | 0 |
| 1 | 10000000 | 128 |
| 2 | 11000000 | 192 |
| 3 | 11100000 | 224 |
| 4 | 11110000 | 240 |
| 5 | 11111000 | 248 |
| 6 | 11111100 | 252 |
| 7 | 11111110 | 254 |
| 8 | 11111111 | 255 |
The powers of two (1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024 and so on) are worth knowing too, because subnet sizes and host counts are always built from them.
Hexadecimal
Hexadecimal uses sixteen digits: 0 to 9, then A (10), B (11), C (12), D (13), E (14) and F (15). One hex digit holds exactly four bits, so a byte is always two hex digits. This neat fit is why hex is used for MAC addresses (12 hex digits = 48 bits) and IPv6 (32 hex digits = 128 bits). Hex values are often written with a 0x prefix to avoid confusion with decimal.
- Hex to binary: replace each hex digit with its four bits.
3F=0011 1111. - Hex to decimal: multiply the left digit by 16 and add the right one.
3F= 3 × 16 + 15 = 63. - Decimal to hex: divide by 16; the whole number is the first digit and the remainder the second. 200 = 12 × 16 + 8 =
C8.
You will meet hex in many places: the EtherType 0x0800 means IPv4 and 0x86DD means IPv6 inside an Ethernet frame; the first half of a MAC address identifies the manufacturer; and IPv6 prefixes are cut on hex digit boundaries. Check your answers with the IP converter and the hex and ASCII converter.
Real-world example: reading a capture at a help desk
A support engineer at a college was asked why a new laptop could not reach a lab server. In a packet capture she saw the laptop sending frames with EtherType 0x86DD but none with 0x0800, and the laptop's address began fe80. She recognised immediately that the laptop was only speaking IPv6 on the link and had no IPv4 address at all. The cause was a DHCP scope that had run out of leases. Without the hex knowledge she would have had to look up every field; with it, the fault took a few minutes to find and the scope was enlarged.
Practice
Convert 237 to binary.
What is the hexadecimal value 0xB4 in decimal and in binary?
Which decimal value is a mask octet with five ones, and how many host addresses does /29 give?
Key takeaways
- Binary place values in an octet are 128, 64, 32, 16, 8, 4, 2 and 1.
- Convert decimal to binary by subtracting the largest place value that fits, left to right.
- Only nine values can appear in a mask octet: 0, 128, 192, 224, 240, 248, 252, 254 and 255.
- One hex digit is four bits (a nibble), so a byte is always two hex digits.
- Hex appears in MAC addresses, IPv6 addresses, EtherTypes and packet captures.
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.