Hexadecimal Representation

BH: SCRAP.

This page has a lot of commented out text that should be read over and removed or moved. --MF, 12/18/17

Typing long strings of ones and zeros is inconvenient and prone to error. A more efficient method is to use hexadecimal (base 16). One hex digit represents any whole number between 0 an 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.

Mary should fix up the CSS in these tables some day. --MF, 12/18/17
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

Place value notation uses 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 3B7: 3 256's 11 16's 7 1's

Mary, you reduced this katex with a style tag (not proper CSS) because you couldn't figure out how to make it work with CSS. Fix this later. --MF, 12/18/17

This stands for 3 \times 256 + 11\times 16 +7\times 1 or 951.

  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.
    Hexadecimal timer

Reading Hexadecimal

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

To translate from hexadecimal (for example, 7B316) 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.

Remember: 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

So, 7B316 = (7 × 256) + (11 × 16) + (3 × 1) = 1792 + 176 + 3 = 197110.

    FF16
    = (15 × 161 + 15 × 160)10
    = (15 × 16 + 15)10
    = 25510
  1. Translate these hexadecimal numerals into base 10 notation:
    1. AF16
    2. 5D16
    3. 1816
    4. 3E816
    A numeral such as 11 means eleven in the usual decimal notation, or three if it is a binary numeral, or seventeen in hexadecimal notation. The only way you know that the "18" in part (c) above doesn't mean eighteen is that subscript "16" means hexadecimal.

Writing Hexadecimal

To translate from base 10 (for example, 29910) to base 16, first write out the hexadecimal 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 two hundred fifty-six once, so I write a 1 there, and there's 43 left. Now, I can subtract two 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 B

Now, read the number off: 12B16 = 29910.

  1. Translate these decimal numerals to hexadecimal notation:
    1. 59
    2. 144
    3. 229
    4. 316

Notice that the algorithms for converting between binary and decimal are the same as the algorithms for converting between hexadecimal and decimal. These algorithms can be used to convert to and from any base.

  1. Talk with Your Partner This algorithm runs into a problem after base 36. What's the problem and what's the solution?
  2. Convert 29910 to base 7.
In the future, consider moving 8.3.3 and 8.3.4 here as TIF and removing from 8.3. --MF, 12/1/17