- Due: 1:30pm Tuesday, 15 September
- Submission: turn in a paper copy in class
- Relevant reading:
- CSAPP 2.1.7 - 2.1.10, 2.2 - 2.3.
- K&R 2.7, 2.9
- Collaboration: This assignment follows the standard collaboration policy. You may discuss problems and high-level strategies with other students, but your solutions must be your own work. You must cite anyone with whom you discussed the problems at the top of your submission.
These short exercises will help familiarize you with number representation and prepare you for the longer Bit Transfiguration assignment.
Most people can count to 10 on their fingers; computer scientists can do better. If you regard each finger as one bit, with finger extended as 1 and finger curled as 0, how high can you count in base 2 using ten fingers and starting at zero? With both ten fingers and ten toes?
Now use both hands and both feet, with your left pinky toe as a sign bit for two’s complement numbers. What is the range of expressible numbers?
Perform the following conversions:
- Show the 8-bit two’s complement representation of -10710 and 10710.
- Show the decimal notation of the signed integers whose 16-bit two’s-complement representations are given in hexadecimal notation as
Perform the following calculations on the 8-bit representation of unsigned integers. Show the unsigned sums in binary and convert the sums to decimal notation too. Indicate for each whether overflow has occurred.
00101101 11111111 00000000 + 01101111 + 11111111 - 11111111 ---------- ---------- ----------
Repeat the same calculations assuming the 8-bit values represent signed integers. Show the signed sums in binary and convert the sums to decimal notation too. Indicate for each whether overflow has occurred.
Perform the following calculations on integer representations notated in hexadecimal. Assume that there is no limit on the number of hex digits we can store, i.e., keep your carries.
5480 CAFF 20D + 8888 - 1BCD * 23 ------ ------ -----
Optional Practice Problems
These problems will get you thinking in the style needed for the Bit Transfiguration assignment.
CSAPP2e Homework Problem 2.76 (p. 126), parts A, B, C, and D.
Thinking about powers of 2 will help.
CSAPP2e Homework Problem 2.81 (pp. 126-127), parts A, D, and E.
An informal prose description suffices to “describe the underlying mathematical principles”. No proof is required.