The Digital World-Homework 1 Solutions

Posted February 2



Exercises

1. Write, in ordinary decimal notation, the integer whose binary representation is 11011001. 

We saw two different algorithms for solving this.  The simpler one for pencil and paper is to mark each place with the corresponding power of 2 (so reading right to left, the places are marked 1,2,4,8,16,32,64,128).  The number represented is the sum of the powers that mark the places with a 1: 128+64+16+8+1=217.

2. Write the binary representation of one hundred sixty-nine

The simplest way for pencil and paper is to repeatedly subtract from the number the largest power of 2 that you can without getting a negative result:

169-128=41
41-32=9
9-8=1
1-1=0.
So 169=128+32+8+1, ir 10101001 in binary.

3. Write the bit pattern of problem 2 in hexadecimal notation.

A9  (you just translate each of the the 4-bit blocks).

4. Add 100101 and 11101011 in binary.  Don't do this by converting to decimal, adding, and then converting back to binary, do the entire problem in binary. Now multiply 11010 and 10111 in binary.

Here's the addition.  The carries are indicated in red along the top row, the sum in the last row.

1 1 1 1 1 1 1
1 0 0 1 0 1
+ 1 1 1 0 1 0 1 1
1 0 0 0 1 0 0 0 0


Here's the multiplication.  The intermediate summands are shown in blue. I do not show the carries generated during the addition phase. There is something a bit difficult here.  When you do the addition, there is a carry into the column containing the X symbol, and thus the sum for this columni is 1+1+1+1=100.  what doe we do with such a 3-digit sum ?  (You're not likely to see this in decimal.)  The answer is that you carry 0 into the next column to the left, and 1 two columns to the left.


1 1 0 1 0
X 1 0 1 1 1
1 1 0 1 0
1 1 0 1 0
1 1 0 1 0
0 0 0 0 0
+ 1 1 0 1 0
1 0 0 1 0 1 0 1 1 0

5. What are the three numbers displayed in the Maya manuscript in the Lecture Notes "Representing Numbers"?  (The base is 20.  Each digit consists of either the eye-shaped thing, which is zero, or between zero and three parallel lines and between 0 and 4 dots.  Each dot represents 1 and each line represents 5, so each digit value is between 0 and 19.  The most significant digit is at the top.)

The first one is 7 2 12, so at base 20, this is 7x202+2x20+12=2852.
Likewise, the next three are 7x202+7x20+2=2942, 8x202+1x20+12=3232, and 8x202+2x20=3240.

6. How many bytes are in the ASCII representation of a  typical novel?  For a typical novel, you can just pick anything off your bookshelf, and make a reasonable estimate.  Explain how you made the estimate.  A CD  has a storage capacity of 650MB.  Approximately how many such novels will fit on a single CD, using the ASCII encoding of one byte per character?

I picked something at random off my bookshelf, and counted the number of lines on one page and the number of characters in one line.  This gave me estimates of 38 lines per page, and 69 characters per line.  The book has 350 pages, which makes approximately 918000 charcters altogether, thus 918000 bytes.

650 MB is 650x1048576=681574400 bytes.  If I divide this by 918000 I get 742.46, which is the approximate  number of novels of this size that can fit on one CD.  If I weren't so tired of counting things, I would count the number of novels on my bookshelf.  I have a lot, but I'm pretty sure it's less than 742, so I think my entire collection would fit on a single CD!


7. Practically no one uses dialup anymore, because they're so slow. The built-in dialup modems on many computers receive and transmit at 56 kilobits per second (if you're lucky).  A kilobit is really one thousand bits, I think. How long would it take to download the entire contents of an audio CD using dialup?

To continue with the calculation above, our CD contains
681574400x8=5452595200, so the transmission would require 5452595200/56000 = 97368 seconds, or about 27 hours.

8. In the directory of numbers in my cell phone, there is a number labeled.

HOWARD WORK

and another labeled

Home

This directory is presumably in alphabetical order, but "HOWARD WORK" comes before "Home". Why is that?

The ASCII encodings of upper-case letters are less than those of lower case letters, so if you arrange in 'alphabetical order', but respect the ASCII ordering, this is what you would get.  Actually, I think this is just laziness on the part of the people who wrote the software for the phone!