CS173: Intro to Computer Science - Number Systems
Activity Goals
The goals of this activity are:- To identify the number systems that represent common data types
- To model colors according to their RGB encoding
Warmup
What is the value of 255 in binary, and in hexadecimal? How about 256?The Activity
Directions
Consider the activity models and answer the questions provided. First reflect on these questions on your own briefly, before discussing and comparing your thoughts with your group. Appoint one member of your group to discuss your findings with the class, and the rest of the group should help that member prepare their response. Answer each question individually from the activity, and compare with your group to prepare for our whole-class discussion. After class, think about the questions in the reflective prompt and respond to those individually in your notebook. Report out on areas of disagreement or items for which you and your group identified alternative approaches. Write down and report out questions you encountered along the way for group discussion.Model 1: ASCII Table
Questions
- What is the decimal representation for the character
'A'
? How about the newline character\n
? - What is the decimal representation for the character
'B'
? How about the character'b'
? What is the difference between them? - What is the difference between each corresponding capital and lowercase letter?
- What is your name in ASCII decimal representation? What is this in binary?
- Write out the representation for the character
'B'
in binary, and also the character'b'
. How does their binary differ? - How do you think a
boolean isLowerCase(char x)
function might work? - How large is an
int
variable in bits? How does this compare to aString
? - What are some ways we could specify the size of a
String
? In other words, how can we know when theString
is finished?
Model 2: RGB Colors
Visit this page: https://www.rapidtables.com/web/color/RGB_Color.html
Questions
- What three colors are used to define all colors on the color wheel?
- What does every greyscale color have in common?
- If you have one, what is the RGB value of your favorite color (or choose any color!)? What is the value of the red, green, and blue components in hexadecimal? What is the value in the "#" box for this color?
- What is the largest and smallest value of red, green, and blue that you can have?
- Given the number of possible reds, greens, and blues, how many total colors can we represent?
- Including black and white, how many possible pure greyscale colors can we represent?
- The complement of a color is the color computed whose red, green, and blue values would create white light when combined with the original color. What mathematical expressions might compute the complement of a color defined in RGB?