Integer Arithmancy
ex Practice number representation and computer arithmetic.
- Due: before class Tuesday, 9 February
- Submit: Bring a paper copy to class.
- Relevant Reference:
- Collaboration: individual ex assignment policy, as defined by the syllabus.
These short exercises will help familiarize you with number representation and prepare you for the longer Bit Transfiguration assignment.
Problem 1
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?
Problem 2
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
0x5F8C
and0xCAFE
.
Problem 3
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 or not overflow has occurred.
00101101 11111111 00000000
+ 01101111 + 11111111 - 11111111
---------- ---------- ----------
Problem 4
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.
Problem 5
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.
Problem 6
CSAPP2e Homework Problem 2.76 (p. 126), parts A, B, C, and D.
Thinking about powers of 2 will help.
Problem 7
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.