COMP 231 - Assignment 2 |
Due in class, Thurs. March 1 |
Problem 1. Write the values 16,777,216 and 16,777,217 as they would be stored as single precision floating point numbers. (Give your answers in hexadecimal.) What if anything is surprising about the answers? How would 16,777,216.5 be represented as a single precision floating point number? Find two values for which a similar phenomenon occurs for double precision.
Problem 2. Do Problem 3.29 on page 231 of the text.
Problem 3.
Problem 4. The standard binary carry-save adder takes 3 binary numbers and re-expresses them as 2 binary numbers with the same sum as the original 3 numbers (the 2 numbers being the carry and the sum). With decimal values, one could easily take more than 3 numbers and reduce them to 2 numbers using the same trick of reducing each column of the addition to the carry and sum digits. How many decimal numbers could you reduce in this way to 2 numbers? What about for binary numbers? Why doesn't one take 4 numbers and reduce them to 2? If instead of reducing to 2 numbers we take X numbers and reduce them to 3 numbers with the same sum, how large can X be if we want to use the natural generalization of this trick? Estimate how large (in terms of the number of AND and OR gates) a depth 2 circuit (using a PLA for example) that performs the reduction of X to 3 numbers for your X . If this circuit was used to add n numbers what would be the depth of the resulting tree of X to 3 adders? (Express your answer using Big Oh notation.)
Problem 5. An elegant number system for representing signed integers is called the balanced ternary number system. In this system each position in the number represents a power of 3. The first (rightmost) position is 30, the next is 31, then 32 etc. But rather than use as digits the values 0, 1 and 2 (which would be the ordinary ternary system), one uses the digits -1, 0 and 1. For -1 we will write 1. For example the number -8 is written as 101 since in decimal this would be -1*32 + 0*31 + 1*30. What value does 101101 correspond to? Each of the digits is called a trit in this system. What values can be represented with n trits? Given a number x in balanced ternary notation, describe a simple algorithm to decide if it is positive or negative. Describe a simple algorithm for finding -x. Describe an algorithm for converting a number in decimal notation to one in balanced ternary notation.
Report problems to dkrizanc at wesleyan dot edu
![]() |