1.2 Network Math  
  1.2.8 Hexadecimal  
Hexadecimal (hex) is used frequently when working with computers since it can be used to represent binary numbers in a more readable form. The computer performs computations in binary, but there are several instances when the binary output of a computer is expressed in hexadecimal to make it easier to read.

Converting a hexadecimal number to binary, and a binary number to hexadecimal, is a common task when dealing with the configuration register in Cisco routers. Cisco routers have a configuration register that is 16 bits long. The 16-bit binary number can be represented as a four-digit hexadecimal number. For example, 0010000100000010 in binary equals 2102 in hex. The word hexadecimal is often abbreviated 0x when used with a value as shown with the above number: 0x2102.

Like the binary and decimal systems, the hexadecimal system is based on the use of symbols, powers, and positions. The symbols that hex uses are 0 - 9, and A, B, C, D, E, and F.

Notice that all possible combinations of four binary digits have only one hexadecimal symbol, where it takes two in decimal. The reason why hex is used is that two hexadecimal digits, as opposed to decimal that would require up to four digits, can efficiently represent any combination of eight binary digits. In allowing two decimal digits to represent four bits, using decimal could also cause confusion in reading a value. For example, the eight bit binary number 01110011 would be 115 if converted to decimal digits. Is that 11-5 or 1-15? If 11-5 is used, the binary number would be 1011 0101, which is not the number originally converted. Using hexadecimal, the conversion is 1F, which always converts back to 00011111.

Hexadecimal reduces an eight bit number to just two hex digits. This reduces the confusion of reading long strings of binary numbers and the amount of space it takes to write binary numbers. Remember that hexadecimal is sometimes abbreviated 0x so hex 5D might be written as "0x5D".

To convert from hex to binary, simply expand each hex digit into its four bit binary equivalent.

 

Lab Activity

Hexadecimal Conversions

In this lab, the student will learn the process to convert hexadecimal values to decimal and binary values.

     
 

Web Links

The Hexadecimal Number System

http://www.math.ohiou.edu/~just/hex.htm