Integer Arithmancy
ex Practice number representation and computer arithmetic.
- Assign: Thursday, 2 February
- Due: before class Monday, 6 February
- Collaboration: individual ex assignment policy, as defined by the syllabus and honor code.
- Submit: Bring a typed or neatly handwritten paper copy of this standard answer sheet to class.
- Relevant Reference:
Please download, print (2-sided), and write your answers on this standard sheet to help us grade and provide feedback to you faster.
Problem 1
Most people can count to 10 on their fingers; computer scientists can do better. Write answers to these expressions as simple arithmetic expressions or exact numbers in base ten.
- 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? (10-bit two’s complement)
- What is the maximum fingers-and-toes-complement (20-bit two’s 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 your work and do the calculuations in binary. Additionally, convert the sum to decimal notation. Indicate for each calculation whether or not overflow has occurred.
00101101 11111111 00000000
+ 01101111 + 11111111 - 11111111
---------- ---------- ----------
Problem 4
Repeat all parts of problem 3 assuming the 8-bit values represent signed integers in two’s complement representation.