intro to computer science lab
CS1150 Introduction to Computer Science
Lab #3 – Representing Numbers, 40 points
Objective:
To understand how negative and real numbers encoded inside computers.
Instructions:
Make sure to do the Activities as outlined in the LabCH03.pdf and LabCH04.pdf files. The activity is actually a tutorial that will help you to solve the problems in the exercises. It is expected that you will complete the Activities before you begin the exercises.
When you are finished, save and rename the completed document as “firstname_lastname_lab3.docx”. Then, submit the saved document to Pilot.
Activity:
- LabCH03.pdf
· Activity
· Part 1
- LabCH04.pdf
· Activity
· Part 1
· Part 2
· Part 3
Exercise 1: Representing Negative Numbers
1) Start the “Negative binary numbers” applet.
a. Type in -1 and press “Enter” key. Study the result. Find the “sign bit”. How does the applet indicate it? Come up with a theory of how the sign bit is indicated/ what the rule is for determining which bit is the sign bit. Try and test your theory to be sure. See if you can prove and/or disprove it. Write down your theory of how the sign bit is indicated:
b. Change the number of bits to 32 in the text field “Number of digits in binary” and convert -1 again. Write down how the two forms of binary -1 are different in 32 bits compared to 8 bits. (Feel free to convert -1 into 8 bits again to see the different forms.)
2) a. Fill in the table you made with the binary values for these two numbers (6 and -6), changing the number of bits from 8 to 16, and then to 32.
6
-6
8 bits
16 bits
32 bits
b. Using the applet, change the number size back to 8 bits. Type in 127 and press Enter. Describe what you see below.
3) a) Now type in -127 to the “Negative binary numbers” applet and convert. Write down the values. What is the difference between +127 and -127 in 2’s complement form?
b) Perform 38 + (-52) by converting the numbers to binary and use 8 bits. Write each and every step required to perform this operation including the 2’s complement conversion.
4) Type 4 into the “number of digits in binary” field. Then convert the number 8. What do you see? Does this seem right? How many bits you need to represent 8?
Write down your reasoning and answer:
Exercise 2: Representing Characters
- Start the “Character codes” applet.
a. Type 100 into the top text area and press “Enter” (or click on the Convert to Character button). Write down what you see.
b. Type in 68 and do the same. What relation does this character have to the first one?
c. Do the same for 101 and 69, and for 102 and 70. Write down the codes and the characters you see.
d. What conclusion can you draw about how upper- and lowercase characters in ASCII are represented, based on your experiments?
(HINT:If you are still stuck, fill out this table.)
Code
Letter
68
100
69
101
70
102
- If you were writing an algorithm or formula to capitalize text for a word-processing program, what simple mathematical transformation would you make to the character codes to capitalize a letter?
- Now type in 232, 233, 234, and 235, one at a time.
a. Write down what you see for each one. (Copy from applet and paste it here)
232:
233:
234:
235:
b. What characteristics do these characters share?
- What does ASCII code 241 look like? (Copy from applet and paste it here)
Exercise 3: Text Translator
- Start the “Text Encoding in ASCII” applet. Type in a short sentence and press “Enter” or click on “translate text” button. Paste your screenshot below.
- Suppose you wrote an essay and your word processor reported that it contained 10,000 characters. How many bits would your computer need to store the essay using ASCII codes? How many bytes is that?
- Scroll the tall window on the left to see all the ASCII codes. Write down the numerical codes for these symbols:
__ ½
__ ¼
__ ¾
__ x (multiplication)
__ ÷ (division)
__ ±
Exercise 4: Representing Colors
- Start the “Color maker” applet.
a. Select Yellow from the names choice pull-down menu. Write down the RGB and HSB values.
RGB:
HSB:
b. Now select Magenta and do the same.
RGB:
HSB:
- Suppose you heard that Kathy’s favorite color was 0,255,0. What would Kathy call that color?
- Pick a color from the pull-down list of names in the center, and gradually slide the saturation scrollbar toward the top so that the value in the box below “Sat” goes down to 0. Test various colors and figure out which color doesn’t change.
- Pick another color from the pull-down list and gradually slide the brightness scrollbar toward 0. What color do you end up with? Is this true of any color?
- Set 140 into the Red box by scrolling it . Then type 0 into the green box and press return, and do the same for the blue box. Take a screenshot of the applet, and paste it here, below this line:
Rubric (40 pts possible):
Exercise
Points
1
Question 1
2
Question 2
2
Question 3
4
Question 4
2
2
Question 1
4
Question 2
2
Question 3
2
Question 4
2
3
Question 1
2
Question 2
2
Question 3
6
4
Question 1
2
Question 2
2
Question 3
2
Question 4
2
Question 5
2
Total
40
What Students Are Saying About Us
.......... Customer ID: 12*** | Rating: ⭐⭐⭐⭐⭐"Honestly, I was afraid to send my paper to you, but splendidwritings.com proved they are a trustworthy service. My essay was done in less than a day, and I received a brilliant piece. I didn’t even believe it was my essay at first 🙂 Great job, thank you!"
.......... Customer ID: 14***| Rating: ⭐⭐⭐⭐⭐
"The company has some nice prices and good content. I ordered a term paper here and got a very good one. I'll keep ordering from this website."