Integer Arithmancy
ex Practice number representation and computer arithmetic.
- Assign: Monday, 12 September
- Due: before class Monday, 19 September
- Submit: Bring a typed or neatly handwritten 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 just ten toes, with the left pinky toe as a sign bit for two’s (toes) complement numbers. What is the minimum expressible number?
- What is the maximum fingers-and-toes-complement number?
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 in two’s complement representation. Show the sums in binary and convert the sums to decimal notation too. Indicate for each whether overflow has occurred.
Optional Practice Problems
These problems will get you thinking in the style needed for the Bit Transfiguration assignment.
- CSAPP3e Homework Problem 2.77. Thinking about powers of 2 will help.
- CSAPP3e Homework Problem 2.82. An informal prose description suffices to “describe the underlying mathematical principles”.