1. Random Numbers In The Social Atom (2007), author Mark Buchanan says "Take a piece of whisper-thin paper, say 0.1 mm thick. Now suppose you fold it in half twenty-five times in a row, doubling its thickness each time. How thick will it be? Almost everyone asked such a question will grossly underestimate the result." Right now, make your own estimate, which you should be able to do in your head on the basis of what we've done in class. When you do the rest of this exercise you can assess whether you are better than "almost everyone". (a) If Buchanan is correct about the thickness of a piece of paper, how thick will the folded paper be? .1mm * 2^25, or about 3 million mm, or 3 km or equivalent. watch out for too much precision. (b) Is Buchanan's estimate of 0.1 mm much too high, much too low, or about right, and why? (You can make your own estimate by observation near printers.) very close to right. if you measure a standard ream of paper like those found near printers, 500 sheets is about 5+ cm or 50 mm, so 10 sheets is 1 mm. (c) Von Neumann's Preliminary discussion of the logical design of an electronic computing instrument (1946) says (§5.2), "... a binary coding of the decimal system -- each decimal digit being represented by at least a tetrad of binary digits. Thus an accuracy of ten decimal digits requires at least 40 binary digits. In a true binary representation of numbers, however, about 33 digits suffice to achieve a precision of 1010. The use of the binary system is therefore somewhat more economical of equipment than is the decimal." Is 33 bits enough to represent decimal numbers as large as 1010, and why do you say so? 2^33 is only about 8.6 * 10^9, which is less than 10^10 (d) For practice, write out the decimal value 109 in binary, in hex, and in tetrads (a representation which today is often called "binary coded decimal": 4 bits for each decimal digit). 1101101 6D 0001 0000 1001 2. Bloody Instructions (a) Von Neumann discusses an architectural tradeoff: whether to include an instruction for multiplication or to synthesize it by using the addition instruction. What section of the 1946 paper first raises this issue? How would you summarize the tradeoff in a single sentence? section 1.5 the idea is that "a multiplication operator would run faster but require more complicated hardware." (b) The toy simulator (toysim.html) is a Javascript program running in a web page. The toy machine does not have a multiply instruction. Modify the simulator by adding a multiply instruction, with the operation name mul. (The Javascript multiplication operator is *.) add two lines that look more or less like this, in the right place: else if (opcode[pc] == "mul") accumulator = parseFloat(accumulator) * parseFloat(litoradr(adr[pc])) 3. Get With the Program (a) Write a program that gets one integer from the keyboard and prints three times its value (e.g., if the number is 10, the program prints 30.) This should be about 6 lines long, or 4 lines if you use your mul instruction. Think about the class example that adds two numbers. get mul 3 print stop or a variant that doesn't use mul, like get store n add n add n print stop n 0 no penalty for redundant operations if it would work. and it was ok to say just "store" and "add"; the toy machine by accident just refers to some random but always the same array element and programs "work" by accident. i'll fix this some day. (b) Write a program that gets one number from the keyboard, prints that number and successive lower numbers down to 0 inclusive, then stops. For instance, if the initial number is 4, the program prints 4, 3, 2, 1, 0 on successive lines. get top print ifzero done sub 1 goto top done stop or any variant that works; again, no problem if there is redundant code as long as the output would be right. be sure that the boundary conditions like 0 work and include the initial value and 0 in the output. and it has to work if the input value is 0. no penalty if it doesn't work for negative numbers; that wasn't part of the problem.