1. L.O: STUDENTS WILL BE
ABLE TO EXPLAIN HOW
COMPUTERS USE HEX.
30-60 minutes (about 1 class period)
DO NOW: READ
Unit 4 Lab 1: Number
Representation, Page 4
2. Using
Hex:
THIS SUITCASE
IS BINARY
THIS SUITCASE IS
HEX
We can pack four bits (binary
digits) into one hexadecimal
digit because 16 is a power of
two (16 = 24).
So, a group of four bits
represents a value between 0
and 15, and one hex digit also
represents values from 0-15
(using 0-9 and A-F). This
makes it easier to translate
between binary and hex than
between other bases.
3. Translating between
Binary and Hex
• To translate a binary numeral (like
11010111012) to hexadecimal,
start by splitting it into groups of
four bits, from right-to-left (like
this: 11 0101 1101)
• Then determine the value of each
group and write the
corresponding hex digit (look it up
on the table at right)
BINARY HEX
00002 016
00012 116
00102 216
00112 316
01002 416
01012 516
01102 616
01112 716
10002 816
10012 916
10102 A16
10112 B16
11002 C16
11012 D16
11102 E16
You can create a table like this
whenever you need one
EX: 112 = 316, 01012 = 516, and 1101 =
D16.
So, 11010111012
=35D16
.
FOR YOU TO DO:
Translate these binary numerals to
hexadecimal notation:
1.1110112
2.11011112
3.101100012
5. Translating Hex TO
BINARY
• To translate a HEX numeral (like
4E116) to Binary, write each
hex digit as a group of four
bits, ( write that way even
if the binary
representation doesn’t
need all four digits)
• For ex: 416 = 01002, E16 =
11102, and 1 = 00012.
BINARY HEX
00002 016
00012 116
00102 216
00112 316
01002 416
01012 516
01102 616
01112 716
10002 816
10012 916
10102 A16
10112 B16
11002 C16
11012 D16
11102 E16
You can create a table like this
whenever you need one
4E116 =0100111000012 or just 100111000012
Translate these
hexadecimal numerals to
binary notation:
a. 1816
b.5D16
c. F816
Remember: practice makes perfect.
On the AP exam, you’ll have to
translate binary to hex and vice
versa!
7. Computers have several ways of
representing colors: RGB (red, green, blue)
CMYK (cyan, magenta, yellow, black)….
RGB (red, green, blue) is used for screen displays,
They use CMYK (cyan, magenta, yellow, black) is used for
printing…
On a computer screen, each pixel—each dot that
makes up the picture on the screen—is assigned an
RGB color defined by the intensity of red, green, and
blue in that color.
The three color intensities each range from 0
to 255 (one byte is used for each of the three
colors), which is 00 to FF in hex notation.
8. If (R, G, B) = (128, 0, 255), the color is
purple: some red and a lot of blue, but no
green at all.
If all three colors are as bright as
possible (all are 255), we see white
if they are as dark as possible
(0,0,0), we see black.
Instead of writing (255, 255, 255) for white and (128, 0, 255)
for purple, we often use hex notation: FFFFFF and 8000FF.
And this color is red 255, green 127, and blue 0, which is
FF7F00 in hex.
9. Represent these colors in hex notation:
a.red 0, green 149, and blue 235
b.red 128, green 90, and blue 0
c. red 163, green 0, and blue 84
a.red 0, green 149, and blue 235 is 0095EB in
hex
b.red 128, green 90, and blue 0 is 805A00 in
hex
c.red 163, green 0, and blue 84 is A30054 in
hex
10. •Predict what this RGB
color will look like based
on its values: red 145,
green 0, blue 226.
•Predict what this hex RGB
color will look like: 04FF61.
11. If There Is Time…
• Explore this RGB/HEX color
converter:
http://hex.colorrrs.com/
• Play with this Interactive Color
Wheel
• Read more about RGB colors and
hexadecimal notation.
12. Take It Further (Extension Activities)
A. Load the Snap! RGB library into one of your
projects to explore RGB color further. In the
File menu, choose "Libraries..." and then
choose "Set RGB or HSV pen color". This will
give you a new "Pen" block:
As in all Snap! blocks, the
numeric input slots take values
in base 10 (not hex). Each color
component has a value between
0 and 255
13. 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]
14. Enduring Understandings:
•EU 2.1 A variety of
abstractions built upon
binary sequences can be
used to represent all
digital data.
15. 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
16. 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.
17. 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.
18. 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
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.
Page 4: Using Hex.
Understand how to translate numerals between hexadecimal and binary notations.
Understand that colors can be represented using hexadecimal notation and that this is done in HTML.
Page 4: Using Hex.
Understand how to translate numerals between hexadecimal and binary notations.
Understand that colors can be represented using hexadecimal notation and that this is done in HTML.
Page 4: Using Hex.
Remind students that the purpose of computer science is to abstract away the details; that's why, for example, "orange" (which browsers also understand) is a much better representation for that color than "FF7F00."