Advanced Placement Computer Science AB:
Assignment 2
    Sewickley Academy, 2000-2001

See Course Home Page.  Also, see the Solutions to Assignment 2

Note:  Solo only -- you may not work in teams on this assignment.
 
Date Assigned: Mon Sep-11
Date Due: Tue Sep-12 by start of P8

For each of the following problems, you must show the intermediate steps of your work.  Final answers without supporting work will not be counted.

1.  Consider the 4-character string Mp3!  (Be careful about upper and lower case.)  If this is represented in ASCII, give the resulting 32-bit sequence.   Call this x.

2.  Consider the number -603.28125.  If this is represented in floating point notation, give the resulting 32-bit sequence.  Call this y.

3.  Compute each of the following values, representing your answers in both binary and hexadecimal.
3a.  x >> 4
3b.  y << 7
3c.  x & y
3d.  ~(~x & ~y)  (The fact that this equals x | y is one of De Morgan's Laws; you still must show your work to prove it is true, at least in this case.)

4.  Consider again 4-character strings represented in ASCII in a 32-bit sequence x.  Describe a combination of the operators discussed in today's lecture (and in Appendix A) which can test whether the second and fourth letters of the string are identical.  So, for Yada the test would return TRUE (1), but for Foo! the test would return FALSE (0).

5.  Easier Extra Credit (Not Required, but Strongly Encouraged):  Modify the test from problem 4 case insensitive.  That is, it would return TRUE (1) for any of Yada, YAda, or YadA.

6.  Harder Extra Credit (Not Required, but Strongly Encouraged):  Say you have 74 unsigned 32-bit integers, x1 through x74, and while you don't know the value of any particular xi, you do know the following:

6 xi have the value 203,209
18 xi have the value 1,223,669
17 xi have the value 403
22 xi have the value 202,882,400
9 xi have the value 55
2 xi have the value 88
Your task is to determine the value of applying xor to the entire list.  That is, what is the value (in hexadecimal) of the following:
        x1 xor x2 xor x3 xor x4... xor x73 xor x74?
Be sure to explain your answer.

See Course Home Page.