Chapter 5

Number Systems

Objectives

Upon completion of this chapter, you will be able to answer the following questions:

  • How do you convert numbers between decimal and binary systems?

  • How do you convert numbers between decimal and hexadecimal systems?

Key Terms

This chapter uses the following key terms. You can find the definitions in the glossary at the end of the book.

dotted decimal page 176

binary page 176

hexadecimal page 176

Introduction (5.0)

Guess what? This is the 32-bit binary IPv4 address of a computer in a network: 11000000.10101000.00001010.00001010. This is the IPv4 address for the same computer in dotted decimal: 192.168.10.10. Which one would you rather work with? Addresses get even more complicated with IPv6, where addresses are 128 bits! To make these addresses more manageable, IPv6 uses the hexadecimal system, which includes the numbers 0 to 9 and the letters A to F.

As a network administrator, you must know how to convert binary addresses into dotted decimal and dotted decimal addresses into binary. You also need to know how to convert dotted decimal into hexadecimal and vice versa. (Hint: You still need your binary conversion skills when converting between dotted decimal and hexadecimal.)

They may seem complicated, but these conversions are not that hard when you learn a few tricks. The module that corresponds to this chapter contains an activity called the Binary Game, which will really help you get started. Why wait?

Binary Number System (5.1)

IPv4 addresses are 32-bit addresses expressed in decimal notation. This section discusses the binary number system along with the conversion between the binary and decimal number systems.

Binary and IPv4 Addresses (5.1.1)

IPv4 addresses begin as binary, series of only 1s and 0s. These are difficult to manage, so network administrators convert them to decimal. This section shows you a few ways to do this.

Binary is a numbering system that consists of the digits 0 and 1, called bits. In contrast, the decimal numbering system consists of the digits 0 to 9.

It is important to understand binary because hosts, servers, and network devices use binary addressing. Specifically, they use binary IPv4 addresses, as shown in Figure 5-1, to identify each other.

The breakdown of IPv4 address of a network is shown.

Figure 5-1 IPv4 Address in Binary Format

Each address consists of a string of 32 bits, divided into four sections called octets. Each octet contains 8 bits (or 1 byte), and each pair of octets is separated with a dot. For example, PC1 in Figure 5-1 is assigned IPv4 address 11000000.10101000.00001010.00001010. Its default gateway address would be that of the R1 Gigabit Ethernet interface: 11000000.10101000.00001010.00000001.

Binary works well with hosts and network devices. However, it is very challenging for humans to work with. For ease of use by people, IPv4 addresses are commonly expressed in dotted decimal notation. Figure 5-2 shows the same network as Figure 5-1, but here PC1 is assigned the IPv4 address 192.168.10.10, and its default gateway address is 192.168.10.1.

The breakdown of IPv4 address in a dotted decimal format.

Figure 5-2 IPv4 Addresses in Dotted Decimal Format

For a solid understanding of network addressing, it is necessary to know binary addressing and gain practical skills converting between binary and dotted decimal IPv4 addresses. The following sections cover how to convert between base 2 (binary) and base 10 (decimal) numbering systems.

Video—Converting Between Binary and Decimal Numbering Systems (5.1.2)

Video.

Refer to the online course to view this video.

Binary Positional Notation (5.1.3)

Learning to convert binary to decimal requires an understanding of positional notation. Positional notation means that a digit represents different values depending on the “position” the digit occupies in the sequence of numbers. You already know the most common numbering system, the decimal (base 10) notation system.

The decimal positional notation system operates as described in Table 5-1.

Table 5-1 Decimal Positional Notation

Radix

10

10

10

10

Position in number

3

2

1

0

Calculate

(103)

(102)

(101)

(100)

Positional value

1000

100

10

1

The following bullets describe the rows in Table 5-1:

  • Row 1 (radix) is the number base. Decimal notation is based on 10, so the radix is 10.

  • Row 2 (position in number) considers the position of the decimal number starting with, from right to left, 0 (1st position), 1 (2nd position), 2 (3rd position), 3 (4th position). These numbers also represent the exponential values used to calculate the positional value in the 4th row.

  • Row 3 (calculate) calculates the positional value by taking the radix and raising it by the exponential value of its position in row 2.

Note

n0 is = 1.

  • Row 4 (positional value) represents units of thousands, hundreds, tens, and ones.

To use the positional system, match a given number to its positional value. The example in Table 5-2 illustrates how positional notation is used with the decimal number 1234.

Table 5-2 Example of Using Decimal Positional Notation

 

Thousands

Hundreds

Tens

Ones

Positional Value

1000

100

10

1

Decimal Number (1234)

1

2

3

4

Calculate

1 × 1000

2 × 100

3 × 10

4 × 1

Add Them Up…

1000

+ 200

+ 30

+ 4

Result

1234

 

 

 

In contrast, the binary positional notation operates as described in Table 5-3.

Table 5-3 Binary Positional Notation

Radix

2

2

2

2

2

2

2

2

Position in number

7

6

5

4

3

2

1

0

Calculate

(27)

(26)

(25)

(24)

(23)

(22)

(21)

(20)

Positional value

128

64

32

16

8

4

2

1

The following bullets describe the rows in Table 5-3:

  • Row 1 (radix) is the number base. Binary notation is based on 2, so the radix is 2.

  • Row 2 (position in number) considers the position of the binary number starting with, from right to left, 0 (1st position), 1 (2nd position), 2 (3rd position), 3 (4th position). These numbers also represent the exponential value use to calculate the positional value in the 4th row.

  • Row 3 (calculate) calculates the positional value by taking the radix and raising it by the exponential value of its position in row 2.

Note

n0 is = 1.

  • Row 4 (positional value) represents units of ones, twos, fours, eights, and so on.

The example in Table 5-4 illustrates how a binary number 11000000 corresponds to the number 192. If the binary number had been 10101000, then the corresponding decimal number would be 168.

Table 5-4 Example of Using Binary Positional Notation

Positional Value

128

64

32

16

8

4

2

1

Binary Number (11000000)

1

1

0

0

0

0

0

0

Calculate

1 × 128

1 × 64

0 × 32

0 × 16

0 × 8

0 × 4

0 × 2

0 × 1

Add Them Up…

128

+ 64

+ 0

+ 0

+ 0

+ 0

+ 0

+ 0

Result

192

 

 

 

 

 

 

 

Check Your Understanding—Binary Number System (5.1.4)

Interactive Graphic.

Refer to the online course to complete this activity.

Convert Binary to Decimal (5.1.5)

To convert a binary IPv4 address to its dotted decimal equivalent, divide the IPv4 address into four 8-bit octets. Then apply the binary positional value to the first octet binary number and calculate accordingly.

For example, say that 11000000.10101000.00001011.00001010 is the binary IPv4 address of a host. To convert the binary address to decimal, start with the first octet, as shown in Table 5-5. Enter the 8-bit binary number under the positional value of row 1 and then calculate to produce the decimal number 192. This number goes into the first octet of the dotted decimal notation.

Table 5-5 Converting 11000000 to Decimal

Positional Value

128

64

32

16

8

4

2

1

Binary Number (11000000)

1

1

0

0

0

0

0

0

Calculate

1 × 128

1 × 64

0 × 32

0 × 16

0 × 8

0 × 4

0 × 2

0 × 1

Add Them Up…

128

+ 64

+ 0

+ 0

+ 0

+ 0

+ 0

+ 0

Result

192

 

 

 

 

 

 

 

Next, convert the second octet of 10101000 as shown in Table 5-6. The resulting decimal value is 168, and it goes into the second octet.

Table 5-6 Converting 10101000 to Decimal

Positional Value

128

64

32

16

8

4

2

1

Binary Number (10101000)

1

0

1

0

1

0

0

0

Calculate

1 × 128

0 × 64

1 × 32

0 × 16

1 × 8

0 × 4

0 × 2

0 × 1

Add Them Up…

128

+ 0

+ 32

+ 0

+ 8

+ 0

+ 0

+ 0

Result

168

 

 

 

 

 

 

 

Convert the third octet of 00001011 as shown in Table 5-7.

Table 5-7 Converting 00001011 to Decimal

Positional Value

128

64

32

16

8

4

2

1

Binary Number (00001011)

0

0

0

0

1

0

1

1

Calculate

0 × 128

0 × 64

0 × 32

0 × 16

1 × 8

0 × 4

1 × 2

1 × 1

Add Them Up…

0

+ 0

+ 0

+ 0

+ 8

+ 0

+ 2

+ 1

Result

11

 

 

 

 

 

 

 

Convert the fourth octet of 00001010 as shown in Table 5-8. This completes the IP address and produces the dotted decimal result 192.168.11.10.

Table 5-8 Converting 00001010 to Decimal

Positional Value

128

64

32

16

8

4

2

1

Binary Number (00001010)

0

0

0

0

1

0

1

0

Calculate

0 × 128

0 × 64

0 × 32

0 × 16

1 × 8

0 × 4

1 × 2

0 × 1

Add Them Up…

0

+ 0

+ 0

+ 0

+ 8

+ 0

+ 2

+ 0

Result

10

 

 

 

 

 

 

 

Activity—Binary to Decimal Conversions (5.1.6)

Interactive Graphic.

This activity allows you to practice 8-bit binary to decimal conversion as much as necessary. We recommend that you work with this tool until you are able to do the conversion without error. Convert the binary number shown in the octet to its decimal value.

Refer to the online course to complete this activity.

Decimal to Binary Conversion (5.1.7)

It is also necessary to understand how to convert a dotted decimal IPv4 address to binary. A useful tool is the binary positional value table. Figures 5-3 through 5-10 show examples of this type of table. The following steps walk through how to use this table to do the conversion:

How To icon.

Step 1. In Figure 5-3, is the decimal number of the octet (n) equal to or greater than the most significant bit (128)?

  • If no, then enter binary 0 in the 128 positional value.

  • If yes, then add a binary 1 in the 128 positional value and subtract 128 from the decimal number.

The criteria for adding a binary value in the 128th positional value is shown.

Figure 5-3 128 Positional Value

Step 2. In Figure 5-4, is the decimal number of the octet (n) equal to or greater than the next most significant bit (64)?

  • If no, then enter binary 0 in the 64 positional value.

  • If yes, then add a binary 1 in the 64 positional value and subtract 64 from the decimal number.

The criteria for adding a binary value in the 64th positional value is shown.

Figure 5-4 64 Positional Value

Step 3. In Figure 5-5, is the decimal number of the octet (n) equal to or greater than the next most significant bit (32)?

  • If no, then enter binary 0 in the 32 positional value.

  • If yes, then add a binary 1 in the 32 positional value and subtract 32 from the decimal number.

The criteria for adding a binary value in the 32nd positional value is shown.

Figure 5-5 32 Positional Value

Step 4. In Figure 5-6, is the decimal number of the octet (n) equal to or greater than the next most significant bit (16)?

  • If no, then enter binary 0 in the 16 positional value.

  • If yes, then add a binary 1 in the 16 positional value and subtract 16 from the decimal number.

The criteria for adding a binary value in the 16th positional value is shown.

Figure 5-6 16 Positional Value

Step 5. In Figure 5-7, is the decimal number of the octet (n) equal to or greater than the next most significant bit (8)?

  • If no, then enter binary 0 in the 8 positional value.

  • If yes, then add a binary 1 in the 8 positional value and subtract 8 from the decimal number.

The criteria for adding a binary value in the 8th positional value is shown.

Figure 5-7 8 Positional Value

Step 6. In Figure 5-8, is the decimal number of the octet (n) equal to or greater than the next most significant bit (4)?

  • If no, then enter binary 0 in the 4 positional value.

  • If yes, then add a binary 1 in the 4 positional value and subtract 4 from the decimal number.

The criteria for adding a binary value in the 4th positional value is shown.

Figure 5-8 4 Positional Value

Step 7. In Figure 5-9, is the decimal number of the octet (n) equal to or greater than the next most significant bit (2)?

  • If no, then enter binary 0 in the 2 positional value.

  • If yes, then add a binary 1 in the 2 positional value and subtract 2 from the decimal number.

The criteria for adding a binary value in the 2nd positional value is shown.

Figure 5-9 2 Positional Value

Step 8. In Figure 5-10, is the decimal number of the octet (n) equal to or greater than the last most significant bit (1)?

  • If no, then enter binary 0 in the 1 positional value.

  • If yes, then add a binary 1 in the 1 positional value and subtract 1 from the last decimal number.

The criteria for adding a binary value in the 1st positional value is shown.

Figure 5-10 1 Positional Value

Decimal to Binary Conversion Example (5.1.8)

To help understand the process of converting from decimal to binary, consider the IP address 192.168.11.10.

The first octet number, 192, is converted to binary using the previously explained positional notation process.

It is possible to bypass the process of subtraction with easier or smaller decimal numbers. For instance, notice that it is fairly easy to calculate the third octet converted to a binary number without actually going through the subtraction process (8 + 2 = 10). The binary value of the third octet is 00001010.

The fourth octet is 11 (8 + 2 + 1). The binary value of the fourth octet is 00001011.

Converting between binary and decimal may seem challenging at first, but with practice, it should become easier over time.

Figures 5-11 through 5-21 illustrate the steps to convert the IP address 192.168.10.11 into binary:

Step 1. In Figure 5-11, is the first octet number 192 equal to or greater than the high-order bit 128?

  • Yes it is, so add a 1 to the high-order positional value to represent 128.

  • Subtract 128 from 192 to produce a remainder of 64.

The addition of binary in 128th positional value concerning the first octet is shown.

Figure 5-11 Step 1

Step 2. In Figure 5-12, is the remainder 64 equal to or greater than the next high-order bit 64?

  • It is equal, so add a 1 to next high-order positional value.

The addition of binary in 64th positional value concerning the first octet is shown.

Figure 5-12 Step 2

Step 3. In Figure 5-13, since there is no remainder, enter binary 0 in the remaining positional values.

  • The binary value of the first octet is 11000000.

The binary value of the first octet is shown.

Figure 5-13 Step 3

Step 4. In Figure 5-14, is the second octet number 168 equal to or greater than the high-order bit 128?

  • Yes it is, so add a 1 to the high-order positional value to represent 128.

  • Subtract 128 from 168 to produce a remainder of 40.

Addition of binary in 128th positional value concerning second octet is shown.

Figure 5-14 Step 4

Step 5. In Figure 5-15, is the remainder 40 equal to or greater than the next high-order bit 64?

  • No it is not, so enter a binary 0 in the positional value.

Addition of binary in 64th positional value concerning second octet is shown.

Figure 5-15 Step 5

Step 6. In Figure 5-16, is the remainder 40 equal to or greater than the next high-order bit 32?

  • Yes it is, so add a 1 to the high-order positional value to represent 32.

  • Subtract 32 from 40 to produce a remainder of 8.

Addition of binary in 32nd positional value concerning second octet is shown.

Figure 5-16 Step 6

Step 7. In Figure 5-17, is the remainder 8 equal to or greater than the next high-order bit 16?

  • No it is not, so enter a binary 0 in the positional value.

Addition of binary in 16th positional value concerning second octet is shown.

Figure 5-17 Step 7

Step 8. In Figure 5-18, is the remainder 8 equal to or greater than the next high-order bit 8?

  • It is equal, so add a 1 to next high-order positional value.

Addition of binary in 8th positional value concerning second octet is shown.

Figure 5-18 Step 8

Step 9. In Figure 5-19, since there is no remainder, enter binary 0 in the remaining positional values.

  • The binary value of the second octet is 10101000.

The binary value of the second octet of IP 192.168.10.11 is shown.

Figure 5-19 Step 9

Step 10. In Figure 5-20, the binary value of the third octet is 00001010.

The binary value of the third octet of IP 192.168.10.11 is shown in a positional value table.

Figure 5-20 Step 10

Step 11. In Figure 5-21, the binary value of the fourth octet is 00001011.

The binary value of the fourth octet of IP 192.168.10.11 is shown in a positional value table.

Figure 5-21 Step 11

Activity—Decimal to Binary Conversions (5.1.9)

Interactive Graphic.

This activity allows you to practice decimal conversion to 8-bit binary values. We recommend that you work with this tool until you are able to do the conversion without error. Convert the decimal number shown in the Decimal Value row to its binary bits.

Refer to the online course to complete this activity.

Activity—Binary Game (5.1.10)

Interactive Graphic.

Playing this game is a fun way to learn binary numbers for networking.

Game link: Log in to cisco.com and down load the game from https://learningnetwork.cisco.com/docs/DOC-1803 or https://learningnetwork.cisco.com/docs/DOC-11119. (Create a Cisco account if you do not already have one.)

IPv4 Addresses (5.1.11)

As mentioned at the beginning of this section, routers and computers understand only binary, while humans work in decimal. It is important for you to gain a thorough understanding of these two numbering systems and how they are used in networking.

192.168.10.10 is an IP address that is assigned to a computer, as shown in Figure 5-22.

A figure shows the IP address of a computer and their respective octets. The dotted decimal here is 192.168.10.10. Below this are the following octet sets: For 192- 11000000; for 168- 10101000; for 10- 00001010; and for 10- 00001010. The dotted decimal values are highlighted.

Figure 5-22 Dotted Decimal Address

This address is made up of four different octets, as shown in Figure 5-23.

A figure shows the IP address of a computer and their respective octets. The dotted decimal here is 192.168.10.10. Below this are the following octets: 1101000, 00001010, 00001010, and 00001010. Each octet set here is highlighted separately.

Figure 5-23 Octets

The computer stores the address as the entire 32-bit data stream, as shown in Figure 5-24.

Breakdown of IP 192.168.10.10 and its respective octet.

Figure 5-24 32-Bit Address

Hexadecimal Number System (5.2)

IPv6 addresses are 128-bit addresses expressed in hexadecimal notation. This section discusses the hexadecimal number system along with the conversion between the hexadecimal and decimal number systems.

Hexadecimal and IPv6 Addresses (5.2.1)

Now you know how to convert binary to decimal and decimal to binary. You need that skill to understand IPv4 addressing in a network. But you are just as likely to use IPv6 addresses in a network. To understand IPv6 addresses, you must be able to convert hexadecimal to decimal and vice versa.

Just as decimal is a base 10 number system, hexadecimal is a base 16 system. The base 16 number system uses the digits 0 to 9 and the letters A to F. Figure 5-25 shows the equivalent decimal and hexadecimal values for binary 0000 to 1111.

Three columns list the decimal, binary, and hexadecimal values.

Figure 5-25 Comparing Decimal, Binary, and Hexadecimal Number Systems

Binary and hexadecimal work well together because it is easier to express a value as a single hexadecimal digit than as 4 binary bits.

The hexadecimal numbering system is used in networking to represent IP version 6 (IPv6) addresses and Ethernet MAC addresses.

IPv6 addresses are 128 bits in length, and every 4 bits is represented by a single hexadecimal digit, for a total of 32 hexadecimal values. IPv6 addresses are not case-sensitive; they can be written in either lowercase or uppercase.

As shown in Figure 5-26, the preferred format for writing an IPv6 address is x:x:x:x:x:x:x:x, with each x consisting of four hexadecimal values. When referring to 8 bits of an IPv4 address, we use the term octet. In IPv6, a hextet is the unofficial term used to refer to a segment of 16 bits or 4 hexadecimal values. Each x is a single hextet, 16 bits, or 4 hexadecimal digits.

The breakdown of an IPv6 address.

Figure 5-26 Hextets of an IPv6 Address

The sample topology in Figure 5-27 displays IPv6 hexadecimal addresses.

The topology of an IPv6 address.

Figure 5-27 Topology with IPv6 Addresses

Video—Converting Between Hexadecimal and Decimal Numbering Systems (5.2.2)

Video.

Refer to the online course to view this video.

Decimal to Hexadecimal Conversions (5.2.3)

Converting decimal numbers to hexadecimal values is a straightforward process that involves the following steps:

How To icon.

Step 1. Convert the decimal number to 8-bit binary strings.

Step 2. Divide the binary strings into groups of four, starting from the rightmost position.

Step 3. Convert each set of 4 binary numbers into the equivalent hexadecimal digit.

Let’s look at an example of converting the decimal number 168 to hexadecimal:

Step 1. 168 in binary is 10101000.

Step 2. 10101000 split into two groups of 4 binary digits is 1010 and 1000.

Step 3. 1010 is hex A, and 1000 is hex 8.

Answer: 168 is A8 in hexadecimal.

Hexadecimal to Decimal Conversion (5.2.4)

Converting hexadecimal numbers to decimal values is also a straightforward process that involves only three steps:

How To icon.

Step 1. Convert the hexadecimal number to 4-bit binary strings.

Step 2. Create 8-bit binary grouping starting from the rightmost position.

Step 3. Convert each 8-bit binary grouping into the equivalent decimal digit.

Here is an example of the steps for converting hex D2 to decimal:

Step 1. D2 in 4-bit binary strings is 1101 and 0010.

Step 2. 1101 and 0010 is 11010010 in an 8-bit grouping.

Step 3. 11010010 in binary is equivalent to 210 in decimal.

Answer: D2 in hexadecimal is 210 in decimal.

Check Your Understanding—Hexadecimal Number System (5.2.5)

Interactive Graphic.

Refer to the online course to complete this activity.

Summary (5.3)

The following is a summary of the topics in the chapter and their corresponding online modules.

Binary Number System

Binary is a numbering system that consists of the numbers 0 and 1, called bits. In contrast, the decimal numbering system consists of the numbers 0 to 9. It is important to understand binary because hosts, servers, and network devices use binary addressing—specifically, binary IPv4 addresses—to identify each other. You must know binary addressing and how to convert between binary and dotted decimal IPv4 addresses. In this chapter you learned a few ways to convert decimal to binary and binary to decimal.

Hexadecimal Number System

Just as decimal is a base 10 number system, hexadecimal is a base 16 system. The base 16 number system uses the numbers 0 to 9 and the letters A to F. The hexadecimal numbering system is used in networking to represent IPv6 addresses and Ethernet MAC addresses. IPv6 addresses are 128 bits in length, and every 4 bits is represented by a single hexadecimal digit, for a total of 32 hexadecimal values. To convert hexadecimal to decimal, you must first convert the hexadecimal to binary and then convert the binary to decimal. To convert decimal to hexadecimal, you must also first convert the decimal to binary.

Practice

There are no labs or Packet Tracer activities for this chapter.

Check Your Understanding Questions

Complete all the review questions listed here to test your understanding of the topics and concepts in this chapter. The appendix “Answers to ‘Check Your Understanding’ Questions” lists the answers.

1. What is the binary representation for the decimal number 173?

  1. 10100111

  2. 10100101

  3. 10101101

  4. 10110101

2. Which address is the dotted decimal equivalent of the binary address 11101100 00010001 00001100 00001010?

  1. 234.17.10.9

  2. 234.16.12.10

  3. 236.17.12.6

  4. 236.17.12.10

3. How many binary bits exist in an IPv6 address?

  1. 32

  2. 48

  3. 64

  4. 128

  5. 256

4. What is the binary equivalent of the decimal number 232?

  1. 11101000

  2. 11000110

  3. 10011000

  4. 11110010

5. Which two statements are correct about IPv4 and IPv6 addresses? (Choose two.)

  1. IPv6 addresses are represented by hexadecimal numbers.

  2. IPv4 addresses are represented by hexadecimal numbers.

  3. IPv6 addresses are 32 bits in length.

  4. IPv4 addresses are 32 bits in length.

  5. IPv4 addresses are 128 bits in length.

  6. IPv6 addresses are 64 bits in length.

6. Which IPv4 address format looks like 201.192.1.14 and was created for ease of use by people?

  1. binary

  2. dotted decimal

  3. hexadecimal

  4. ASCII

7. What is the dotted decimal representation of the IPv4 address 11001011.00000000.01110001.11010011?

  1. 192.0.2.199

  2. 198.51.100.201

  3. 203.0.113.211

  4. 209.165.201.223

8. What is the decimal equivalent of the binary number 10010101?

  1. 149

  2. 157

  3. 168

  4. 192

9. What is the decimal equivalent of the hex number 0x3F? (0x refers to hexadecimal)

  1. 63

  2. 77

  3. 87

  4. 93

10. What is the dotted decimal representation of the IPv4 address represented as the binary string 00001010.01100100.00010101.00000001?

  1. 10.100.21.1

  2. 10.10.20.1

  3. 100.10.11.1

  4. 100.21.10.1

11. What is the decimal equivalent of 0xC9? (0x refers to hexadecimal)

  1. 185

  2. 200

  3. 201

  4. 199

12. Which is a valid hexadecimal number?

  1. f

  2. g

  3. h

  4. j

13. What is the binary representation of 0xCA? (0x refers to hexadecimal)

  1. 10111010

  2. 11010101

  3. 11001010

  4. 11011010

14. How many bits are in an IPv4 address?

  1. 32

  2. 64

  3. 128

  4. 256