1. L.O: STUDENTS WILL LEARN
TO READ HEXADECIMAL
REPRESENTATION
25-50 minutes (about 1 class period)
DO NOW:
READ
Unit 4 Lab 1: Number Representation, Page 3
2. Typing long strings of ones and zeros is
inconvenient very prone to error.
Its easy to make a mistake writing all
those ones and zeros for binary!
Using Hexadecimal (base
16) is a common
compromise
Four binary digits are used to
represent the values 0 through 15.
Only one hex digit is needed to
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.
3. 27 26 25 24 23 22 21 20
128s
place
64s
place
32s
place
16s
place
8s
place
Fours
place
Twos
place
Ones
place
Eight bits in base two…..
…is two digits in base 16
161 160
Sixteens place Ones place
5. In base 16, there are sixteen
digits (0-9 and A-F)….
..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).
6. 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
7. For You to Do:
1. 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
binary
decimals
hex
8. 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
9. Hex to base 10.
To translate from hexadecmial (like 7B316 ) to base
10:
1. first, write the digits on paper.
2. Then write out the hexadecimal place values.
3. start at the right with 1,
4. then write 16 in the next place to the left,
5. then write 256 (which is 162), and so on.
Each new place will be worth 16 times the one to its
right. 7 B 3
256 16 1
This means:
7B316 =
7⋅256 + 11⋅16 + 3⋅1 = 1792 + 176 + 3 = 197110
10. A-F cover the digits after 9:
10 11 12 13 14 15
A B C D E F
11. Sample problem HEX into decimals
FF16
FF16 =
= (15⋅161 + 15⋅160)10
= (15⋅16 + 15)10
= 25510
15. Is “11” the number eleven (in decimal)?
Or three (written in binary)?
Or is it seventeen ( written in hex)?
• 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 ”11” doesn't
mean eleven is that you have write the base:
11 base 16 or just 1116
• (By convention, the base itself is always written in
decimal notation.)
16. Writing Hexadecimal:
translating decimals (base 10) to Hex
(base 16)
To translate from base 10 (like 29910 ) 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.
21. Learning Objectives:
• LO 2.1.1 Describe the variety of
abstractions used to represent
data. [P3]
• LO 2.1.2 Explain how binary
sequences are used to represent
digital data. [P5]
22. Enduring Understandings:
•EU 2.1 A variety of
abstractions built upon
binary sequences can be
used to represent all
digital data.
23. Essential Knowledge:
1. EK 2.1.1A Digital data is represented by
abstractions at different levels.
2. EK 2.1.1B At the lowest level, all digital data are
represented by bits.
3. EK 2.1.1C At a higher level, bits are grouped to
represent abstractions, including but not limited
to numbers, characters, and color.
4. EK 2.1.1D Number bases, including binary,
decimal, and hexadecimal, are used to represent
and investigate digital data
24. Essential Knowledge:
• 5. EK 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.
• 6. EK 2.1.1F Hexadecimal (base 16) is used to
represent digital data because hexadecimal
representation uses fewer digits than binary.
• 7. EK 2.1.1G Numbers can be converted from any
base to any other base.
• 8. EK 2.1.2A A finite representation is used to
model the infinite mathematical concept of a
number.
25. Essential Knowledge:
• 9. EK 2.1.2B In many programming languages, the
fixed number of bits used to represent characters
or integers limits the range of integer values and
mathematical operations; this limitation can result
in overflow or other errors.
• 10.EK 2.1.2C In many programming languages, the
fixed number of bits used to represent real
numbers (as floating point numbers) limits the
range of floating point values and mathematical
operations; this limitation can result in round off
and other errors.
26. Essential Knowledge:
• 11. EK 2.1.2D The interpretation of a binary sequence
depends on how it is used.
• 12. EK 2.1.2E A sequence of bits may represent
instructions or data.
• 13. EK 2.1.2F A sequence of bits may represent
different types of data in different contexts.
• 14. EK 6.2.2J The bandwidth of a system is a measure
of bit rate—the amount of data (measured in bits)
that can be sent in a fixed amount of time.
• 15. EK 6.2.2K The latency of a system is the time
elapsed between the transmission and the receipt of a
request.
Editor's Notes
The third page introduces hexadecimal representation, which uses sixteen digits (0-9 and A-F), building on students' understanding of binary. On the fourth page, students learn to translate between hex and binary and about the use of hex in RGB colors. The last page is an optional project in which students build a decimal-to-binary conversion procedure based on and reviewing their work with base 2 representation. Hexadecimal" is often abbreviated just to "hex." Either is fine to use generally, but students should recognize both.
Page 3: Hexadecimal Representation.
Understand how numbers are stored in hexadecimal notation.
Understand how to translate numerals between hexadecimal and decimal notations.
There's no such thing as a "binary number" or a "hexadecimal number." The way we represent a number—as XXXIRoman or 3110 or 111112 or 1F16 or "thirty-one" or "treinta y uno"—is language or notation. The number, itself, is the same, regardless of what language we express it in. It helps the distinction to say "binary numerals" or "binary representation" instead of "binary numbers." Some curriculum materials are less careful. It's not just pedantry; students understand the conversions better when they remain clearly aware that only the notation, not the number, changes. Explicitly making the analogy with Roman numerals may help; students are likely to understand and be able to extend from the idea XXXI and 31 are the same number written different ways.
Page 3: Hexadecimal Representation.
Don't teach hex arithmetic. The goal is for students to become familiar with the notation of hex. Consider translating between representations for a few numbers together at the board.