wpe41.gif (23084 bytes)CIS3355: Business Data Structures
Fall, 2008
 

What is Hexadecimal, and why is it important?

So far we have seen:

bulletIn Decimal (Base 10) there are 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9
bulletIn Binary (Base 2) there are 2 digits: 0 and 1
bulletIn Octal (Base 8) there are 8 digits: 0, 1, 2, 3, 4, 5, 6,  and 7

In the previous tutorial, we noted that Octal was important because it was easy to convert between Octal and Binary, and between Binary and Octal. This was easy because 23 = 8, meaning that we could represent all of the digits from 0 to 7 (the digits available in octal) using three bits. For example, the octal value 7038 could readily be readily converted to its binary equivalent value (1110000112) simply by mapping the equivalent values for each of the octal digits:

7 0 3
111 000 011

Hexadecimal (Hex) follows the logic of octal, however since hexadecimal consists of 16 digits (as opposed to 8 in octal), 4-bits are grouped together (again, versus 3-bits in octal). Naturally this is because 24 = 16, meaning that we can represent 16 digits using four bits:

Decimal Octal Hexadecimal Binary
0 0 0 0000
1 1 1 0001
2 2 2 0010
3 3 3 0011
4 4 4 0100
5 5 5 0101
6 6 6 0110
7 7 7 0111
8 10 8 1000
9 11 9 1001
10 12 A 1010
11 13 B 1011
12 14 C 1100
13 15 D 1101
14 16 E 1110
15 17 F 1111

Wait, Wait !!! What is this 'A', 'B', 'C', 'D', 'E' and 'F' stuff ??

Remember, a digit is represented by a single character. Decimal digits are the 'characters' 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. Octal 'characters' are the digits , 1, 2, 3, 4, 5, 6, and 7. There is no character for the number ten ('10' consists of two characters). Since we do not have single 'characters' for the numeric values 10, 11, 12, 13, 14, and 15, we must create new characters:

Decimal Hexadecimal
··· ···
9 9
10 A
11 B
12 C
13 D
14 E
15 F

OK, so how does this work ??

Assume we have the binary value: 1 0 0 1 1 1 0 1 0 1 1 1 0 1 02. As we learned in the prior tutorial, the octal value is:

 

100 111 010 111 010
4 7 2 7 2

The only difference between Octal and Hex is that we consider 4-bits at a time (from right to left):

100 1110 1011 1010
4 E B A

The numeric value 4EBA ??

Sure, why not?

Can you prove that this is really the value of 1001110101110102 ??

Let's do it the hard way (but a good way to illustrate the principles involved). let's take the binary value:

1 0 0 1 1 1 0 1 0 1 1 1 0 1 02

then convert it to decimal then convert it to Hex, and then convert it back to binary.

 

 

Let's try it a different way. Let's take the binary value then covert it into Hex, then convert it to decimal, and then back into binary:

 

How does this relate to Octal ??

The two bases are directly related. This time, let's take the value A60B16 and convert it to Octal:

Notice that the major difference between hex and octal is the number bits grouped together (4 in Hex; 3 in Octal)

How do we know the Octal and Hex values are the same??

To check, let's convert them both into decimal:

Some good references to help you better understand Hexadecimal include:

http://vwop.port5.com/beginner/bhextut.html
http://www.danbbs.dk/~erikoest/hex.htm
http://whatis.techtarget.com/definition/0,,sid9_gci212247,00.html

http://www.cookwood.com/html/extras/hexchart.html
http://sislands.com/coin70/week1/qlesson.htm
http://alumni.cs.loyola.edu/~mcoffey/info/eq-chart.htmlhttp://depts.washington.edu/ubms/lectures.html

Some Questions you should be able to answer:

  1. What is 279510 in Hexadecimal.

  2. What 3AF16 in Decimal, Binary and Octal?

  3. What is 11101001001112 In Hex and Octal?

  4. What is 670328 in Binary and Hex? 

Answers:

 

 

 

 

 

 

 

This page was last updated on 05/28/05