2010 February 16 / j d a v i s @ c a r l e t o n . e d u

This assignment helps you practice with the concepts introduced in the Binary tutorial. We covered most of it in class, but you should read through it for the parts that we missed. You are allowed to work through the assignment with other students, but each student must submit his/her own solutions individually, on paper. Show all of your work. If you use multiple pages, then they must be stapled — not paper-clipped or loose. The assignment is due Friday at the start of class.

A. Find the 32-bit binary numeral corresponding to 1234. Also, find the 32-bit expansion of the string "1234", regarding each character as an 8-bit numeral according to ASCII. (This question is intended to emphasize that the integer 1234 and the string "1234" are represented by completely different 32-bit words.)

B. Add 0010001100100001_{2} and 0100100111101111_{2}.

C. Multiply 00001101_{2} and 00000110_{2}.

D. Overflow errors happen more frequently in multiplication than in addition, because the product of two integers is usually much larger than their sum. In unsigned 8-bit binary, how big can the two numbers be, before their product overflows? Give me a rule of the form "As long as the two numbers being multiplied are no longer than ____ bits, their product will not overflow."

E. Compute the difference 98 - 114 in 8-bit two's complement (by using negation and addition).

F. Give an example of how the rule *a* - *b* = *a* + -*b* fails in the 4-bit sign bit system. That is, find two 4-bit numerals that, when interpreted as signed integers according to the sign bit system, violate the rule (and demonstrate that they violate it).

G. In floating-point numbers, why does the first digit of the significand (the digit before the ".") not need to be stored?

H. How many bits does Bopagopa require to store an RGB color, if Python's `float`

is double-precision?

I. Express "orange, halfway between transparent and opaque" as a 32-bit RGBA color, in hexadecimal.