Hexadecimal Representation

2.1 A variety of abstractions built upon binary sequences can be used to represent all digital data.
2.1.1 Describe the variety of abstractions used to represent data. [P3]
2.1.1B At the lowest level, all digital data are represented by bits.
2.1.1C At a higher level, bits are grouped to represent abstractions, including but not limited to numbers, characters, and color.
2.1.1D Number bases, including binary, decimal, and hexadecimal, are used to represent and investigate digital data.
2.1.1E At one of the lowest levels of abstraction, digital data is represented in binary (base 2) using only combinations of the digits zero and one.
2.1.1F Hexadecimal (base 16) is used to represent digital data because hexadecimal representation uses fewer digits than binary.
2.1.1G Numbers can be converted from any base to any other base.

Typing long strings of ones and zeros is inconvenient very prone to error. One common compromise is to use hexadecimal (base 16). Four binary digits represent the values 0 through 15, whereas only one hex digit also represents 0 through 15. So eight digits of binary can be translated into two digits of hexadecimal, which is much easier and much less error-prone for humans.

Eight bits in base two...
27 26 25 24 23 22 21 20
128s place 64s place 32s place 16s place eights place fours place twos place ones place
...is two digits in base 16.
161 160
sixteens place ones place

For example: 12110 = 011110012 = 7916
0 1 1 1 1 0 0 1
7 9

By convention, place value notations use only one digit in each place. We need to represent 0 through 15, and we have digits for 0-9, so we choose A-F for the remaining values:
10 11 12 13 14 15
A B C D E F
In base 16, there are sixteen digits (0-9 and A-F), and each place is worth sixteen times the place to its right. One hex digit has 16 possible values, the equivalent of four binary digits (bits).
place values in hexadecimal

  1. Talk with Your Partner Watch this Hexadecimal and Binary Timer Snap! program run. The top row counts in binary, the middle in decimal, the bottom in hex. Write a description of the hex counter's behavior.

Reading Hexadecimal

place values in binary Base 16 uses powers of sixteen instead of powers of two or ten. Place values in hexadecimal represent the units place (160 = 1), the sixteens place (161 = 16), the two hundred fifty-sixes place (162 = 256), the four thousand ninety-sixes place (163 = 4096), etc. So, for example:

3B16   =   3 × 161  +  11 × 160   =   48  +  11   =   5910

This video continues one you saw before.

Set Up Your Headphones or Speakers
If your connection blocks YouTube, watch the video here, but only watch the segment about converting hexadecimal to decimal from 3:12 to 4:55.

To translate from hexadecmial (like 7B3_{16}) to base 10, first, write the digits on paper. Then write out the hexadecimal place values: start at the right with 1, then write 16 in the next place to the left, then write 256 (which is 162), and so on. Each new place will be worth 16 times the one to its right.

A-F cover the digits after 9:
10 11 12 13 14 15
A B C D E F
7 B 3
256 16 1
right-to-left arrow

This means 7B3_{16} = 7 \cdot 256 + 11 \cdot 16 + 3 \cdot 1 = 1792 + 176 + 3 = 1971_{10}.

    \text{FF}_\text{16}
    = (15 \cdot 16^1 + 15 \cdot 16^0)_\text{10}
    = (15 \cdot 16 + 15)_\text{10}
    = 255_{10}
  1. Translate these hexadecimal numerals into base 10 notation:
    1. AF16
    2. 5D16
    3. 1816
    4. 3E816
    A numeral like 11 could mean eleven in the usual decimal notation, or three if it is a binary numeral, or seventeen in hex notation. The only way you know that the "18" in the last problem doesn't mean eighteen is that the problem said that the numerals were hex. If we need to be extra-clear, we write 18_\text{base 16} or just 18_{16}. (By convention, the base itself is always written in decimal notation.)

Writing Hexadecimal

To translate from base 10 (like 299_{10}) to base 16, first write out the hex place values by multiplying by 16 moving left from the units place until you get to a value larger than your number (4096 for this example). Then think, "My number is smaller than 4096, so I leave that place blank. But I can subtract a two hundred fifty-six once, so I write a 1 there, and there's 43 left. Now, I can subtract 2 sixteens, and there's 11 left. And 11 is B in hex.

299
43
11
0
right-to-left arrow
4096 256 16 1
  1 2 11 (B)

Now, read the number off: 12\text{B}_{16}=299_{10}.

If your connection blocks YouTube, watch the video here, but only watch the segment about translating decimal to hexadecimal from 3:14 to 4:38.
Set Up Your Headphones or Speakers
  1. Translate these decimal numerals to hexadecimal notation:
    1. 59
    2. 144
    3. 229
    4. 316