Hexadecimal Representation

Introduction

A record of our civilization for extraterrestrial beings is attached to the exterior of the Voyager spacecraft (see Figure 1).  How to play the record and the solar system's location are displayed using the binary number system with "_" meaning "0" and "|" indicating "1".

Figure 1  Cover of the Voyager Record on Voyager.  (Source:  "Voyager's Interstellar Outreach Program" at http://vraptor.jpl.nasa.gov/voyager/record.html)

Similarly, the computer stores numbers using the Integer Storage module binary or base 2 number system which only has only two binary digits, 0 and 1. The long strings of bits in the binary number system of the computer are difficult for people to read. Imagine writing programs with only 0's and 1's in the days before high-level languages! To keep insanity from setting in, we use the hexadecimal number representation as an abbreviation.


Conversion from Binary to Decimal Numbers


While the binary number system has two digits and the hexadecimal system 16, the decimal or base 10 number system that we use every day has 10 digits, 0 through 9. To understand binary representations, let us first consider the decimal number 5863, five thousand eight hundred sixty-three. The number consists of 5 thousands, 8 hundreds, 6 tens, and 3 ones. In expanded form, we have

5863 = 5 (1000) + 8 (100) + 6 (10) + 3 (1)

Notice that 1, 10, 100, and 1000 are all powers of 10: 100, 101, 102, 103, respectively.

Thus, we could write

5863 = 5 (103) + 8 (102) + 6 (101) + 3 (100)

We represent numbers in base 2 similarly; but there are only 2 digits ( 0 and 1); and the expansion is in powers of 2, not 10. Hence, in the binary number 1101, rightmost number, 1, indicates the number of 1's; the 0 to the left indicates the number of 2's; the next 1 represents the number of 22's or 4's; while the leftmost 1 gives the number of 23's or 8's. The expansion reveals the decimal or base 10 representation of the number.

(23) + 1 (22) + 0 (21) + 1 (20)

= 1 (8) + 1 (4) + 0 (2) + 1

= 8 + 4 + 0 + 1

= 13

Thus, 1101 in binary is 13 in decimal. When there is a possibility of confusion, we will write the base as a subscript to the number, such as 11012 and 1310.

Definition The binary or base 2 number system has two digits, 0 and 1. Reading a binary integer from right to left, the bit gives the number of units (20's), 21's, 22's, 23's, ...

 

Quick Review Question
Quick Review Question 1  Give the decimal number that 101102 represents.



Conversion from Hexadecimal to Decimal Numbers

Zero is the smallest unsigned integer that we can express in four bits, as 0000. The largest such number is 11112 = 23 + 22 + 21 + 20 = 8 + 4 + 2 + 1 = 15. Thus, we can express 16 integers, from 0 through 15, in four bits. As Figure 2 illustrates, the hexadecimal or base 16 number system is an abbreviation for the binary system.

Figure 2  First 16 nonnegative integers with decimal, binary, and hexadecimal representations

Decimal
Binary
Hexadecimal
Decimal
Binary
Hexadecimal
0
    0
0
8
1000
8
1

    1

1
9
1001
9
2

  10

2
10
1010
A
3
  11
3
11
1011
B
4
100
4
12
1100
C
5
101
5
13
1101
D
6
110
6
14
1110
E
7
111
7
15
1111
F

In the binary or base 2 system we have 2 digits, 0 and 1; and in the decimal or base 10 system there are 10, 0 through 9. Similarly, in the hexadecimal or base 16 system, we must use new symbols to arrive at the 16 hexadecimal (hex) digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. Conversion from hexadecimal to decimal involves the same procedure as conversion from binary to decimal, except the expansion is in powers of the base, 16, instead of powers of 2.

Definition The hexadecimal or base 16 system has 16 hexadecimal (hex) digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.


Example 1. To express the hexadecimal unsigned integer 5C with the equivalent decimal number, we must convert the hexadecimal digits to decimal numbers as well as expand: A-> 10,  B -> 11,  C -> 12,  D -> 13,  E -> 14,  F -> 15.  Thus,

5C = 5(161) + 12(160)

   = 5 (16) + 12 (1)

   = 92

Quick Review Question
Quick Review Question 2  Express the hexadecimal unsigned integer 1DF with the equivalent decimal number.

    
Exercises

Express the binary numbers in Exercises 1-9 in the decimal number system.

1. 111   2. 1011   3. 1000
4. 1111   5. 10010   6. 110001
7. 111101   8. 1000000   9. 10011010

Express the hexadecimal numbers of Exercises 10-15 in decimal notation.

10. E2   11. 987   12. FFF
13. A4   14. CDD3   15. 4E8


16. Express the hexadecimal numbers from Exercise 10-15 in binary notation.


Copyright � 2002, Dr. Angela B. Shiflet
All rights reserved