Number Systems
Why Binary?
Computers use binary (base-2) because transistors — the fundamental building blocks of all processors and memory — have exactly two states: on (1) or off (0). Everything a computer stores, processes, or transmits is ultimately represented as a sequence of 1s and 0s.
In networking, this matters most for IP addresses. An IPv4 address is a 32-bit binary number split into four groups of 8 bits called octets. Each octet can represent any value from 0 to 255 (since 2^8 = 256 possible values). Understanding binary lets you understand subnetting, subnet masks, and VLSM.
Binary Positional Notation
Just like decimal uses powers of 10 for position values (1s, 10s, 100s, 1000s), binary uses powers of 2. Each position in an 8-bit binary number has a fixed value. The leftmost bit is the Most Significant Bit (MSB) with value 128, and the rightmost is the Least Significant Bit (LSB) with value 1.
| Position | 8 (MSB) | 7 | 6 | 5 | 4 | 3 | 2 | 1 (LSB) |
|---|---|---|---|---|---|---|---|---|
| Value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| 2^n | 2⁷ | 2⁶ | 2⁵ | 2⁴ | 2³ | 2² | 2¹ | 2⁰ |
Binary to Decimal — 5 Worked Examples
To convert binary to decimal: write down the positional values (128, 64, 32, 16, 8, 4, 2, 1), multiply each by the corresponding bit (1 or 0), then add all results.
Position: 128 64 32 16 8 4 2 1 Example 1: 11000000 = 192 Bits: 1 1 0 0 0 0 0 0 Values: 128 + 64 + 0 + 0 + 0 + 0 + 0 + 0 = 192 Example 2: 10101000 = 168 Bits: 1 0 1 0 1 0 0 0 Values: 128 + 0 + 32 + 0 + 8 + 0 + 0 + 0 = 168 Example 3: 00000001 = 1 Bits: 0 0 0 0 0 0 0 1 Values: 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 = 1 Example 4: 11111111 = 255 Bits: 1 1 1 1 1 1 1 1 Values: 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255 Example 5: 00001010 = 10 Bits: 0 0 0 0 1 0 1 0 Values: 0 + 0 + 0 + 0 + 8 + 0 + 2 + 0 = 10
Decimal to Binary — 5 Worked Examples
To convert decimal to binary using the subtraction method: start with the largest positional value (128). If the decimal number is >= 128, write 1 and subtract; otherwise write 0 and move to the next position. Repeat for each position.
Pos: 128 64 32 16 8 4 2 1 Convert 192 → binary 192 >= 128? YES → bit=1, remainder=64 64 >= 64? YES → bit=1, remainder=0 0 >= 32? NO → bit=0 (repeat for 16,8,4,2,1) Result: 11000000 Convert 168 → binary 168-128=40, 40-32=8, 8-8=0 Result: 10101000 Convert 10 → binary 10 < 128,64,32,16 → 0s. 10>=8: 10-8=2. 2>=2: 2-2=0 Result: 00001010 Convert 172 → binary 172-128=44, 44-32=12, 12-8=4, 4-4=0 Result: 10101100 Convert 255 → binary 255-128=127, 127-64=63, 63-32=31, 31-16=15, 15-8=7, 7-4=3, 3-2=1, 1-1=0 Result: 11111111 (all bits set = maximum value)
IP Addresses in Binary
An IPv4 address is really a 32-bit binary number written as four decimal octets for human readability. The subnet mask is also 32 bits: consecutive 1s identify the network portion, and 0s identify the host portion. Understanding this is the foundation of all subnetting.
IP Address: 192.168.10.1 in binary: 192 = 11000000 168 = 10101000 10 = 00001010 1 = 00000001 Full: 11000000.10101000.00001010.00000001 Subnet mask: 255.255.255.0 in binary: 255 = 11111111 <-- network bits (all 1s) 255 = 11111111 <-- network bits 255 = 11111111 <-- network bits 0 = 00000000 <-- host bits (all 0s) Full: 11111111.11111111.11111111.00000000 = /24 prefix notation (24 network bits)
Hexadecimal (Base-16)
Hexadecimal is base-16, using digits 0–9 and then letters A through F for values 10–15. It is widely used in networking because one hex digit represents exactly 4 bits (a nibble), and two hex digits represent one full byte (8 bits). This makes it far more compact and readable than binary for large values.
You will see hex in: MAC addresses (AA:BB:CC:DD:EE:FF), IPv6 addresses (2001:0DB8:85A3::8A2E:370:7334), and Cisco IOS output throughout your CCNA career.
Decimal to Hex (divide by 16, remainders are digits): 255 ÷ 16 = 15 remainder 15 → F 15 ÷ 16 = 0 remainder 15 → F Read remainders bottom-up: FF 192 ÷ 16 = 12 remainder 0 → 0 12 ÷ 16 = 0 remainder 12 → C Read bottom-up: C0 172 ÷ 16 = 10 remainder 12 → C → AC 10 ÷ 16 = 0 remainder 10 → A → 0A Hex to Decimal (multiply each digit by its 16^n position): FF = (F × 16) + F = (15 × 16) + 15 = 240 + 15 = 255 C0 = (C × 16) + 0 = (12 × 16) + 0 = 192 + 0 = 192 2A = (2 × 16) + A = (2 × 16) + 10 = 32 + 10 = 42
MAC Address: AA:BB:CC:DD:EE:FF 6 bytes = 12 hex digits (each byte = 2 hex digits) AA:BB:CC = OUI (manufacturer identifier) DD:EE:FF = Device ID (unique per NIC) IPv6 Address (full form): 2001:0DB8:85A3:0000:0000:8A2E:0370:7334 8 groups × 4 hex digits = 128 bits total IPv6 Abbreviated form (RFC 5952): 2001:DB8:85A3::8A2E:370:7334 Rules: 1) Drop leading zeros in each group 2) Replace longest run of all-zero groups with :: 3) :: can only appear ONCE in an address
AB hex = 1010 1011 binary. A=1010, B=1011. Just look up each hex digit in the table above and write its 4-bit value. This is especially fast when working with MAC addresses and IPv6.