This appendix provides information concerning the following topics:

Now that we have covered how to count (in Appendix A), we need to be able to convert between the three different number systems. This is another skill that takes time and practice to become comfortable using, and it is a skill that can quickly be lost without usage.

## How to Convert from Decimal to Binary

Remember that in the binary number system, we use 2 as our base number, giving us a chart that looks like this:

… | 2^{10} | 2^{9} | 2^{8} | 2^{7} | 2^{6} | 2^{5} | 2^{4} | 2^{3} | 2^{2} | 2^{1} | 2^{0} |

1 024 | 512 | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |

Re-create this chart right before taking an exam. It is quick to write out on a piece of paper (or the erasable board you get in a vendor exam) and will help you with your addition. I have seen many students lose marks because of simple addition errors.

Each of these numbers represents a bit that has been turned on; that is, represented by a 1 in a bit pattern. So, to convert a decimal number to binary, you must add up these numbers to equal the decimal number—those numbers are then turned on and converted to 1 in the pattern:

1200 | = | 1024 + 128 + 32 + 16 | = | 10010110000 |

755 | = | 512 + 128 + 64 + 32 + 16 + 2 + 1 | = | 1011110011 |

500 | = | 256 + 128 + 64 + 32 + 16 + 4 | = | 111110100 |

233 | = | 128 + 64 + 32 + 8 + 1 | = | 11101001 |

187 | = | 128 + 32 + 16 + 8 + 2 + 1 | = | 10111011 |

160 | = | 128 + 32 | = | 10100000 |

95 | = | 64 + 16 + 8 + 4 + 2 + 1 | = | 1011111 |

27 | = | 16 + 8 + 2 + 1 | = | 11011 |

In IPv4, we use 32 bits to represent an IP address. These 32 bits are broken down into four groups of 8 bits. Each group is called an *octet*. You should become very comfortable with working with octets and being able to convert decimal into octets and vice versa. When working with octets, it is customary to insert leading 0s in their placeholders so that all positions in the octet are represented:

95 | = | 64 + 16 + 8 + 4 + 2 + 1 | = | 01011111 |

27 | = | 16 + 8 + 2 + 1 | = | 00011011 |

Some numbers are used over and over again in IPv4 addresses, so these conversions will be easy to remember:

2^{7} | 2^{6} | 2^{5} | 2^{4} | 2^{3} | 2^{2} | 2^{1} | 2^{0} | ||||

Decimal # | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | = | Binary # | |

0 | = | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | = | 00000000 |

1 | = | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | = | 00000001 |

64 | = | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | = | 01000000 |

128 | = | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | = | 10000000 |

192 | = | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | = | 11000000 |

224 | = | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | = | 11100000 |

240 | = | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | = | 11110000 |

248 | = | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | = | 11111000 |

252 | = | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | = | 11111100 |

254 | = | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | = | 11111110 |

255 | = | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 11111111 |

## How to Convert from Binary to Decimal

When converting binary numbers to decimal, we need to use the base-2 chart just like when converting decimal to binary:

… | 2^{10} | 2^{9} | 2^{8} | 2^{7} | 2^{6} | 2^{5} | 2^{4} | 2^{3} | 2^{2} | 2^{1} | 2^{0} |

1 024 | 512 | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |

Re-create this chart right before taking an exam. It is quick to write out on a piece of paper (or the erasable board you get in a vendor exam) and will help you with your addition. I have seen many students lose marks because of simple addition errors.

Using this chart as our guide, we add up all the numbers that are represented by a 1 in the binary pattern to convert it to a decimal number:

101011110000 | = | 1024 + 256 + 64 + 32 + 16 + 8 | = | 1400 |

1011110011 | = | 512 + 128 + 64 + 32 + 16 + 2 + 1 | = | 755 |

111100010 | = | 256 + 128 + 64 + 32 + 2 | = | 482 |

11100100 | = | 128 + 64 + 32 + 4 | = | 228 |

10111010 | = | 128 + 32 + 16 + 8 + 2 | = | 186 |

10101010 | = | 128 + 32 + 8 + 2 | = | 170 |

1001101 | = | 64 + 8 + 4 + 1 | = | 77 |

1101 | = | 8 + 4 + 1 | = | 13 |

Again, we use leading 0s in order to form octets:

01001101 | = | 64 + 8 + 4 + 1 | = | 77 |

00001101 | = | 8 + 4 + 1 | = | 13 |

## How to Convert from Decimal IP Addresses to Binary and from Binary IP Addresses to Decimal

To convert a decimal IP address to binary, we need to take each individual number and convert it to binary:

192.168.10.1 | |||||

192 | = | 11000000 | |||

168 | = | 10101000 | |||

10 | = | 00001010 | |||

1 | = | 00000001 | |||

= | 11000000 10101000 00001010 00000001 | ||||

172.16.100.254 | |||||

172 | = | 10101100 | |||

16 | = | 00010000 | |||

100 | = | 01100100 | |||

254 | = | 11111110 | |||

= | 10101100 00010000 01100100 11111110 |

When writing out IP addresses in binary, it is customary to put either a space or a period between the octets:

10101100 00010000 01100100 11111110 *or* 10101100.00010000.01100100.11111110

To convert a binary IP address to decimal, we need to take each individual binary number and convert it to decimal:

11000000 10101000 01100100 11110011 | |||||

11000000 | = | 192 | |||

10101000 | = | 168 | |||

01100100 | = | 100 | |||

1111011 | = | 243 | |||

= | 192.168.100.243 | ||||

00001010 10010110 01100000 00000001 | |||||

00001010 | = | 10 | |||

10010110 | = | 150 | |||

01100000 | = | 96 | |||

00000001 | = | 1 | |||

= | 10.150.96.1 |

### A Bit of Perspective

In the IPv4 addressing scheme, there are 2^{32} potential unique addresses that are mathematically possible. If we didn’t use the dotted-decimal format of breaking down 32-bit address into four groups of 8 bits, we may have to use numbers like 3,232,238,081 for 192.168.10.1, or 84,215,041 instead of 10.10.10.1. Which would be easier for you to remember?

## How to Convert from Hexadecimal to Binary

This is a conversion that you will be using more than converting hex to decimal. It is very simple to do. Each hex digit can be represented by four binary digits using the following table:

Hex | Binary |

0 | 0000 |

1 | 0001 |

2 | 0010 |

3 | 0011 |

4 | 0100 |

5 | 0101 |

6 | 0110 |

7 | 0111 |

8 | 1000 |

9 | 1001 |

A | 1010 |

B | 1011 |

C | 1100 |

D | 1101 |

E | 1110 |

F | 1111 |

Re-create this chart right before taking an exam. It is quick to write out on a piece of paper (or the erasable board you get in a vendor exam) and will help you with your conversions. I have seen many students lose marks because of simple errors.

When converting hex to binary, it is customary to convert pairs of hex digits to binary octets, as shown in Example 1.

**Example 1:** Convert C9 to Binary

Step 1 | C | = | 1100 |

Step 2 | 9 | = | 1001 |

Therefore | C9 | = | 11001001 |

If there is an uneven number of hex digits to make a complete octet, put a leading 0 at the *beginning* of the hex number, as shown in Example 2.

**Example 2:** Convert DB8 to Binary

Step 1 | D | = | 1101 |

Step 2 | B | = | 1011 |

Step 3 | 8 | = | 1000 |

Therefore | DB8 | = | 00001101 10111000 |

Leading 0s are used to complete the first octet (DB8 = 0DB8)

## How to Convert from Binary to Hexadecimal

This is also a conversion that you will be using more than converting decimal to hex. Using the same table as shown in the preceding section, convert each octet of binary to a pair of hex digits, as shown in Example 3.

**Example 3:** Convert 11000101 to Hex

Step 1 | 1100 | = | C |

Step 2 | 0101 | = | 5 |

Therefore | 11000101 | = | C5 |

If there is an uneven number of binary digits to make a complete octet, put one or more leading 0s at the *beginning* of the binary number, as shown in Example 4.

**Example 4:** Convert 111111110101 to Binary

Step 1 | 1111 | = | F |

Step 2 | 1111 | = | F |

Step 3 | 0101 | = | 5 |

Step 4 | Because there aren’t enough hex digits to make a complete pair, add leading 0s to complete the pair. In this case, add 0000 to the beginning of the number. | ||

Therefore | 0000111111110101 | = | 0F F5 |

Leading 0s are used to complete the first octet (0FF5 = FF5)

Although it takes an extra step, I find it faster to convert hexadecimal digits to binary and then binary to decimal. I can add and subtract faster than multiplying and dividing by 16s.

Example 5 shows the process for converting an entire IP address from hex to decimal.

**Example 5:** Convert the IP Address C0A80101_{HEX} to Decimal

Step 1 | C0 | = | 11000000 | = | 192 |

Step 2 | A8 | = | 10101000 | = | 168 |

Step 3 | 01 | = | 00000001 | = | 1 |

Step 4 | 01 | = | 00000001 | = | 1 |

Therefore | C0A80101_{HEX} | = | 192.168.1.1 |

IPv4 addresses are not usually represented in hexadecimal; an exception is when you are capturing traffic with software such as Wireshark, which shows all traffic in hex.

## How to Convert from Decimal to Hexadecimal

Although this type of conversion is not used very often, you should still understand how to convert a decimal number to a hexadecimal number. To do this conversion, you have to use long division while leaving the remainders in integer form—do not use decimal answers!

The steps involved are as follows:

Divide the decimal number by 16. Leave the remainder in integer form (

*no decimals*).Write down the remainder in hexadecimal form.

Divide the result from step 1 by 16.

Write down the remainder in hexadecimal form.

Repeat this process until you are left with an answer of 0.

If there is a remainder, write that down in hexadecimal form.

The hex value is the sequence of remainders from the last one to the first one.

Examples 6, 7, and 8 show how to convert decimal numbers to hexadecimal.

**Example 6:** Convert 188_{10} to Hex

Step 1 | 188 / 16 | = | 11 with a remainder of 12 | 12 in hex is C |

Step 2 | 11 / 16 | = | 0 with a remainder of 11 | 11 in hex is B |

Therefore | 188_{10} | = | BC_{HEX} |

**Example 7:** Convert 255_{10} to Hex

Step 1 | 255 / 16 | = | 15 with a remainder of 15 | 15 in hex is F |

Step 2 | 15 / 16 | = | 0 with a remainder of 15 | 15 in hex is F |

Therefore | 255_{10} | = | FF_{HEX} |

**Example 8:** Convert 1234_{10} to Hex

Step 1 | 1234 / 16 | = | 77 with a remainder of 2 | 2 in hex is 2 |

Step 2 | 77 / 16 | = | 4 with a remainder of 13 | 13 in hex is D |

Step 3 | 4 / 16 | = | 0 with a remainder of 4 | 4 in hex is 4 |

Therefore | 1234_{10} | = | 4D2_{HEX} |

## How to Convert from Hexadecimal to Decimal

This is also a type of conversion that isn’t used very often. This time we will be multiplying by powers of 16 to convert hexadecimal numbers to decimal.

The steps involved are as follows:

Take the last digit (also known as the least significant digit) in the hexadecimal number and multiply it by 16

^{0}. Put this number off to the side for right now.Remember that 16

^{0}= 1, so you are multiplying this digit by 1.Take the second-to-last digit in the hex number and multiply it by 16

^{1}. Also put this number off to the side.You are multiplying this digit by 16.

Continue multiplying the digits with increasing powers of 16 until you are finished multiplying all of the individual hexadecimal digits.

Add up all of the results from your multiplications and you have your answer in decimal.

Examples 9 through 11 show you how to convert a hexadecimal number to decimal.

**Example 9:** Convert C3_{HEX} to Decimal

Step 1 | 3 × 16^{0} | = | 3 × 1 | = | 3 |

Step 2 | C × 16^{1} | = | 12 × 16 | = | 192 |

Therefore | C3_{HEX} | = | 195 |

**Example 10:** Convert 276_{HEX} to Decimal

Step 1 | 6 × 16^{0} | = | 6 × 1 | = | 6 |

Step 2 | 7 × 16^{1} | = | 7 × 16 | = | 112 |

Step 3 | 2 × 16^{2} | = | 2 × 256 | = | 512 |

Therefore | 276_{HEX} | = | 630 |

**Example 11:** Convert FACE_{HEX} to Decimal

Step 1 | E × 16^{0} | = | 14 × 1 | = | 14 |

Step 2 | C × 16^{1} | = | 12 × 16 | = | 192 |

Step 3 | A × 16^{2} | = | 10 × 256 | = | 2560 |

Step 4 | F × 16^{3} | = | 15 × 4096 | = | 61 440 |

Therefore | FACE_{HEX} | = | 64 206 |

The following chart lists the three most common number systems used in networking: decimal, hexadecimal, and binary. Some numbers you will remember quite easily, as you use them a lot in your day-to-day activities. For those other numbers, refer to this chart.

Decimal Value | Hexadecimal Value | Binary Value |

0 | 00 | 0000 0000 |

1 | 01 | 0000 0001 |

2 | 02 | 0000 0010 |

3 | 03 | 0000 0011 |

4 | 04 | 0000 0100 |

5 | 05 | 0000 0101 |

6 | 06 | 0000 0110 |

7 | 07 | 0000 0111 |

8 | 08 | 0000 1000 |

9 | 09 | 0000 1001 |

10 | 0A | 0000 1010 |

11 | 0B | 0000 1011 |

12 | 0C | 0000 1100 |

13 | 0D | 0000 1101 |

14 | 0E | 0000 1110 |

15 | 0F | 0000 1111 |

16 | 10 | 0001 0000 |

17 | 11 | 0001 0001 |

18 | 12 | 0001 0010 |

19 | 13 | 0001 0011 |

20 | 14 | 0001 0100 |

21 | 15 | 0001 0101 |

22 | 16 | 0001 0110 |

23 | 17 | 0001 0111 |

24 | 18 | 0001 1000 |

25 | 19 | 0001 1001 |

26 | 1A | 0001 1010 |

27 | 1B | 0001 1011 |

28 | 1C | 0001 1100 |

29 | 1D | 0001 1101 |

30 | 1E | 0001 1110 |

31 | 1F | 0001 1111 |

32 | 20 | 0010 0000 |

33 | 21 | 0010 0001 |

34 | 22 | 0010 0010 |

35 | 23 | 0010 0011 |

36 | 24 | 0010 0100 |

37 | 25 | 0010 0101 |

38 | 26 | 0010 0110 |

39 | 27 | 0010 0111 |

40 | 28 | 0010 1000 |

41 | 29 | 0010 1001 |

42 | 2A | 0010 1010 |

43 | 2B | 0010 1011 |

44 | 2C | 0010 1100 |

45 | 2D | 0010 1101 |

46 | 2E | 0010 1110 |

47 | 2F | 0010 1111 |

48 | 30 | 0011 0000 |

49 | 31 | 0011 0001 |

50 | 32 | 0011 0010 |

51 | 33 | 0011 0011 |

52 | 34 | 0011 0100 |

53 | 35 | 0011 0101 |

54 | 36 | 0011 0110 |

55 | 37 | 0011 0111 |

56 | 38 | 0011 1000 |

57 | 39 | 0011 1001 |

58 | 3A | 0011 1010 |

59 | 3B | 0011 1011 |

60 | 3C | 0011 1100 |

61 | 3D | 0011 1101 |

62 | 3E | 0011 1110 |

63 | 3F | 0011 1111 |

64 | 40 | 0100 0000 |

65 | 41 | 0100 0001 |

66 | 42 | 0100 0010 |

67 | 43 | 0100 0011 |

68 | 44 | 0100 0100 |

69 | 45 | 0100 0101 |

70 | 46 | 0100 0110 |

71 | 47 | 0100 0111 |

72 | 48 | 0100 1000 |

73 | 49 | 0100 1001 |

74 | 4A | 0100 1010 |

75 | 4B | 0100 1011 |

76 | 4C | 0100 1100 |

77 | 4D | 0100 1101 |

78 | 4E | 0100 1110 |

79 | 4F | 0100 1111 |

80 | 50 | 0101 0000 |

81 | 51 | 0101 0001 |

82 | 52 | 0101 0010 |

83 | 53 | 0101 0011 |

84 | 54 | 0101 0100 |

85 | 55 | 0101 0101 |

86 | 56 | 0101 0110 |

87 | 57 | 0101 0111 |

88 | 58 | 0101 1000 |

89 | 59 | 0101 1001 |

90 | 5A | 0101 1010 |

91 | 5B | 0101 1011 |

92 | 5C | 0101 1100 |

93 | 5D | 0101 1101 |

94 | 5E | 0101 1110 |

95 | 5F | 0101 1111 |

96 | 60 | 0110 0000 |

97 | 61 | 0110 0001 |

98 | 62 | 0110 0010 |

99 | 63 | 0110 0011 |

100 | 64 | 0110 0100 |

101 | 65 | 0110 0101 |

102 | 66 | 0110 0110 |

103 | 67 | 0110 0111 |

104 | 68 | 0110 1000 |

105 | 69 | 0110 1001 |

106 | 6A | 0110 1010 |

107 | 6B | 0110 1011 |

108 | 6C | 0110 1100 |

109 | 6D | 0110 1101 |

110 | 6E | 0110 1110 |

111 | 6F | 0110 1111 |

112 | 70 | 0111 0000 |

113 | 71 | 0111 0001 |

114 | 72 | 0111 0010 |

115 | 73 | 0111 0011 |

116 | 74 | 0111 0100 |

117 | 75 | 0111 0101 |

118 | 76 | 0111 0110 |

119 | 77 | 0111 0111 |

120 | 78 | 0111 1000 |

121 | 79 | 0111 1001 |

122 | 7A | 0111 1010 |

123 | 7B | 0111 1011 |

124 | 7C | 0111 1100 |

125 | 7D | 0111 1101 |

126 | 7E | 0111 1110 |

127 | 7F | 0111 1111 |

128 | 80 | 1000 0000 |

129 | 81 | 1000 0001 |

130 | 82 | 1000 0010 |

131 | 83 | 1000 0011 |

132 | 84 | 1000 0100 |

133 | 85 | 1000 0101 |

134 | 86 | 1000 0110 |

135 | 87 | 1000 0111 |

136 | 88 | 1000 1000 |

137 | 89 | 1000 1001 |

138 | 8A | 1000 1010 |

139 | 8B | 1000 1011 |

140 | 8C | 1000 1100 |

141 | 8D | 1000 1101 |

142 | 8E | 1000 1110 |

143 | 8F | 1000 1111 |

144 | 90 | 1001 0000 |

145 | 91 | 1001 0001 |

146 | 92 | 1001 0010 |

147 | 93 | 1001 0011 |

148 | 94 | 1001 0100 |

149 | 95 | 1001 0101 |

150 | 96 | 1001 0110 |

151 | 97 | 1001 0111 |

152 | 98 | 1001 1000 |

153 | 99 | 1001 1001 |

154 | 9A | 1001 1010 |

155 | 9B | 1001 1011 |

156 | 9C | 1001 1100 |

157 | 9D | 1001 1101 |

158 | 9E | 1001 1110 |

159 | 9F | 1001 1111 |

160 | A0 | 1010 0000 |

161 | A1 | 1010 0001 |

162 | A2 | 1010 0010 |

163 | A3 | 1010 0011 |

164 | A4 | 1010 0100 |

165 | A5 | 1010 0101 |

166 | A6 | 1010 0110 |

167 | A7 | 1010 0111 |

168 | A8 | 1010 1000 |

169 | A9 | 1010 1001 |

170 | AA | 1010 1010 |

171 | AB | 1010 1011 |

172 | AC | 1010 1100 |

173 | AD | 1010 1101 |

174 | AE | 1010 1110 |

175 | AF | 1010 1111 |

176 | B0 | 1011 0000 |

177 | B1 | 1011 0001 |

178 | B2 | 1011 0010 |

179 | B3 | 1011 0011 |

180 | B4 | 1011 0100 |

181 | B5 | 1011 0101 |

182 | B6 | 1011 0110 |

183 | B7 | 1011 0111 |

184 | B8 | 1011 1000 |

185 | B9 | 1011 1001 |

186 | BA | 1011 1010 |

187 | BB | 1011 1011 |

188 | BC | 1011 1100 |

189 | BD | 1011 1101 |

190 | BE | 1011 1110 |

191 | BF | 1011 1111 |

192 | C0 | 1100 0000 |

193 | C1 | 1100 0001 |

194 | C2 | 1100 0010 |

195 | C3 | 1100 0011 |

196 | C4 | 1100 0100 |

197 | C5 | 1100 0101 |

198 | C6 | 1100 0110 |

199 | C7 | 1100 0111 |

200 | C8 | 1100 1000 |

201 | C9 | 1100 1001 |

202 | CA | 1100 1010 |

203 | CB | 1100 1011 |

204 | CC | 1100 1100 |

205 | CD | 1100 1101 |

206 | CE | 1100 1110 |

207 | CF | 1100 1111 |

208 | D0 | 1101 0000 |

209 | D1 | 1101 0001 |

210 | D2 | 1101 0010 |

211 | D3 | 1101 0011 |

212 | D4 | 1101 0100 |

213 | D5 | 1101 0101 |

214 | D6 | 1101 0110 |

215 | D7 | 1101 0111 |

216 | D8 | 1101 1000 |

217 | D9 | 1101 1001 |

218 | DA | 1101 1010 |

219 | DB | 1101 1011 |

220 | DC | 1101 1100 |

221 | DD | 1101 1101 |

222 | DE | 1101 1110 |

223 | DF | 1101 1111 |

224 | E0 | 1110 0000 |

225 | E1 | 1110 0001 |

226 | E2 | 1110 0010 |

227 | E3 | 1110 0011 |

228 | E4 | 1110 0100 |

229 | E5 | 1110 0101 |

230 | E6 | 1110 0110 |

231 | E7 | 1110 0111 |

232 | E8 | 1110 1000 |

233 | E9 | 1110 1001 |

234 | EA | 1110 1010 |

235 | EB | 1110 1011 |

236 | EC | 1110 1100 |

237 | ED | 1110 1101 |

238 | EE | 1110 1110 |

239 | EF | 1110 1111 |

240 | F0 | 1111 0000 |

241 | F1 | 1111 0001 |

242 | F2 | 1111 0010 |

243 | F3 | 1111 0011 |

244 | F4 | 1111 0100 |

245 | F5 | 1111 0101 |

246 | F6 | 1111 0110 |

247 | F7 | 1111 0111 |

248 | F8 | 1111 1000 |

249 | F9 | 1111 1001 |

250 | FA | 1111 1010 |

251 | FB | 1111 1011 |

252 | FC | 1111 1100 |

253 | FD | 1111 1101 |

254 | FE | 1111 1110 |

255 | FF | 1111 1111 |