Binary and Hexadecimal: Read Network Numbers
One number, three representations
Binary (base 2) uses digits 0 and 1. Decimal (base 10) uses 0–9; hexadecimal (base 16, or hex) uses 0–9 and A–F, where A means ten and F means fifteen. These are different ways to write the same quantity. For instance, decimal 192, binary 11000000 and hex 0xC0 are equal. The prefix 0x labels hexadecimal notation; it is not part of the numeric digits.
Bit weights and octets
A bit has two possible values. An octet contains exactly eight bits; networking uses octets for many fields, including the bytes of an IPv4 address. The leftmost bit of the written unsigned binary number has weight 128; the rightmost has weight 1. Add the weights wherever the digit is 1. There are 2^8 = 256 patterns, from 0 through 255. Leading zeros preserve width without changing value.
Weight: 128 64 32 16 8 4 2 1Bits: 1 1 0 0 0 0 0 0Value: 128 + 64 = 192Convert decimal to binary and back
To convert 192, subtract 128 first (64 remains), then 64 (0 remains). Mark those positions 1 and all others 0. Read 10101101 in reverse by adding 128 + 32 + 8 + 4 + 1 = 173. To convert 37, choose 32 + 4 + 1 = 00100101. Always check by summing the selected weights.
Convert with groups of four bits
Each hex digit represents four bits (a nibble). Split an octet into two groups: 1100 means 12 or C; 0000 means 0, so 11000000 = C0. For hex AD, A = 10 and D = 13; 10 × 16 + 13 = 173. In binary AD is 1010 1101. A field written as 0x0800 contains two octets in this display; it is the Ethernet type value 2048 in decimal. The diagram below is notation, not a guarantee of physical transmission order.
Hex C 0Bits 1100 0000Mistakes and practice
Do not read binary 10 as decimal ten: in base 2 it means two. Hex FF is 255, not 256; 256 needs nine binary digits. Preserve eight digits when a task asks for an octet. Practice: convert 0x3A to binary and decimal, then verify both results with weights. Next, use the bit patterns to build masks.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Binary and hexadecimal — knowledge check
Apply offline network mathematics to fictional values.
Which unsigned octet represents decimal 192?
What is decimal 0x3A?
Which eight-bit binary representation equals hexadecimal 0xAD?
How many distinct unsigned patterns fit in one octet?
Which representation shows decimal 5 in an eight-bit field?