MODD / Mr. Hansen

Name: _____________________________

9/19/2013

 

 

Solutions to HW due 9/19/2013

1. Try to solve Challenge #1 from yesterday’s handout. If you simply can’t get it, move on. Hint: The secret message in Challenge #1 is a 6-word sentence.

Solution: Start with the second letter (Y) and take every third letter thereafter. YOU ARE A VERY CLEVER STUDENT.


2. How many gigabytes are in an exabyte?

Solution: Think of KMGTPEZY, which you need to have memorized for the quiz. In powers of 2, we have 10, 20, 30, 40, 50, 60, 70, 80. An exabyte is 260 bytes, and a gigabyte is 230 bytes. Divide to get  That’s a perfectly good answer, but unless the problem specifically asks for an exact answer, you can also estimate as follows: exabyte  gigabyte  and dividing gives  Answer: about 1 billion gigabytes are in an exabyte.


3. A DSL modem with a download speed of 700 kbps is used to transfer a 4 GB movie. Estimate the download time required. (Hint: kbps means “thousands of bits per second.” To convert bps to bytes per second, you might think you should divide by 8, but actually it is much better to divide by 10. The reason is that the transmission of digital data always includes some “extra” bits for flow control and error correction, and dividing the bps by 10 gives an easy and quite reasonable estimate of the number of bytes per second.)

Solution: 700 kbps is approximately 70 KB/sec, by the rule of thumb that says it takes about 10 bits to transmit a byte. (Yes, yes, it is true that 8 bits make a byte, but there is some overhead when transmitting, and 10 bits to get a byte through is a reasonable rule of thumb.) Divide as follows:

That’s a valid answer, and the approximations are fine since the problem asked for an estimate, but most people have no clue how long 57,143 seconds is. Since there are 3600 seconds in an hour (60 minutes
· 60 seconds per minute), we can divide 57,143 by 3600 to get 15.873 hours. Answer: about 16 hours.


4. The 30-year-old laptop computer in Mr. Hansen’s classroom has a total SSD storage capacity of 32 KB.

 

(a) Approximately how many of those computers would be needed to store a terabyte of data?

Solution: 1 terabyte (240 bytes) divided by 32 kilobytes (32 · 210 bytes) is

It is also OK to estimate as follows:

Answer: more than 30 million antique computers would be needed to store the same amount of data as a single typical home PC has on its hard drive nowadays.


(b) Approximately how many times faster is a modern computer running at a clock speed of 3 GHz compared to Mr. Hansen’s old computer running at 2.5 MHz? (GHz means gigahertz, and MHz means megahertz.)

Solution:  The modern computer is 1200 times faster. If you said about 1000 times faster, that is an acceptable estimate.

 


5. In a byte format, what integer is represented by 0xC9? Give the integer (in both decimal and hex) that is 1 greater than that.

Solution: If we had been given a word format of 0x00C9, the answer would be 12(16) + 9(1) = 201. But that’s not what we were given! In a byte format, the leftmost digit tells us the sign of the number, and any lead digit of 8 or above indicates a negative number. What negative number, you ask? To answer that, we must take the twos complement: 0xFF – 0xC9 = 36, and don’t forget to add 1 to get 0x37. The “add 1” step is the step that students often forget. Now, convert 0x37 to decimal: 3(16) + 7(1) = 55, but we remember that a negative sign is required. Final answer: –55.

To get the integer that is 1 greater than –55, we get (obviously) –54 in decimal. In hex, it’s a little harder, but the answer is 0xC9 + 0x01 = 0xCA.


6. Using a dword format and twos complement hex arithmetic, subtract 0x51ABBA3A from 0x380A30B9. Show and explain all steps. After you have computed the final answer in hex, convert the final answer to decimal (base 10), explaining your steps.

Solution: Strictly speaking, we don’t “subtract” the 0x51ABBA3A. Instead, we add its complement. The complement is 0xFFFFFFFF – 0x51ABBA3A = 0xAE5445C5, to which we must add 1. Therefore, the complement is 0xAE5445C6. Now, we can do the addition as follows:

   1    1
 0x380A30B9
+0xAE5445C6
 0xE65E767F

Look at the answer. Is the lead digit 8 or more? Yes, it is. Therefore, we must treat the answer as a negative number, and to determine which negative number it is, we must take the complement. The complement of 0xE65E767F is 0xFFFFFFFF – 0xE65E767F = 0x19A18980, to which we must add 1 (don’t forget!) to get 0x19A18981. Then convert that to decimal: 1(167) + 9(166) + 10(165) + 1(164) + 8(163) + 9(162) + 8(16) + 1(1) = 430,016,897. Don’t forget that that’s supposed to be negative! Final answer: –430,016,897.

Remember, you are allowed to make some mistakes along the way without losing points, as long as your overall conceptual approach is solid, and as long as your work is neat and complete. A correct answer with missing work will not earn full credit. A wrong answer with good, neat work will usually earn full credit.


7. Convert the 3-byte text string STA (all capitals) into hex. Then convert the 3-byte text string NCS (also all capitals) into hex. Then, treating both results as if they were hex integers in dword format, add them together. Show your work.

Solution: The string "STA" is the ASCII sequence 0x535451, and the string "NCS" is the ASCII sequence 0x4E4353. Treating these as numbers in dword format means that we have to pad with 0’s at the beginning in order to get the proper length. After adding, we have

     1
 0x00535451
+0x004E4353
 0x00A197A4


Final answer: 0x00A197A4. Technically, the leading double 0 is required, since the requested format was dword. However, omitting the leading double 0 would be only a small point deduction.


Optional (bonus): In #7, convert the final answer into base 10, showing your work.

Solution: 10(165) + 1(164) + 9(163) + 7(162) + 10(16) + 4(1) = 10,590,116. Note: This is a positive number, since the lead hex digit (namely, 0) is not 8 or more.