
CPSC 2105 Introduction to Computer Organization
Take-Home Midterm Due at 1:00 PM on Monday March 13, 2006
SHOW ALL OF YOUR WORK.
NO CREDIT GIVEN FOR ANSWERS THAT SHOW NO WORK.
DO NOT PLACE ANY WORK ON THIS SHEET.
1. (10 points) What is the range of integers that can be represented in 12 binary bits
a) if the integers are stored as unsigned numbers?
b) if the integers are stored as two’s–complement signed numbers?
ANSWER: In this, we recall that 212 = 4096 and 211 = 2048.
a) Unsigned N–bit integers range from 0 to 2N – 1, so 12–bit integers
range from 0 to 212 – 1 or 0 to 4095.
b) Signed N–bit integers in two’s complement form range from –2N–1 to 2N–1 –1.
For 12–bit numbers, this is –211 to 211 –1, or –2048 to 2047.
2. (10 points) Convert the following decimal integers to 12–bit two’s–complement form.
Show your work as most calculator will do this automatically.
a) 1023 b) – 1984
ANSWER: We first convert to binary and then pad out to 12 bits.
a) 1023 = 512 + 256 + 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1
= 29 + 28 + 27 + 26 + 25 + 24 + 23 + 22 + 21 + 20
= 11 1111 1111 = 0011 1111 1111, or 0x3FF.
b) 1984 = 1024 + 960 = 1024 + 512 + 448
= 1024 + 512 + 256 + 192 = 1024 + 512 + 256 + 128 + 64
= 1210 +129 + 128 + 127 + 126 + 025 + 024 + 023 + 022 + 021 + 020
= 11111 000000 = 0111 1100 0000
One’s complement is 1000 0011 1111
Add 1 to get 1000 0100 0000, or 0x840.
One could also notice that 1984 = 31 64 = 31 26, so we first covert 31 to 1 1111 and
put six zeroes after it to get 1 1111 000000 or 0111 1100 0000.
Note also that the 12–bit binary number 1000 0100 0000 has six zeroes at its end, so we
divide by 26 = 64 to get 1111 1110 0001, this being 1000 01 with the sign bit copied to
to fill in the first six positions.
Let – X = 1111 1110 0001
One’s complement 0000 0001 1110
Add one 0000 0001 1111, or 31.
100, 100, 99, 99, 98, 98, 95, 95, 95, 95, 92.
86, 85, 84, 81, 79, 68, 45
Page 1 of 6 pages Exam Key Revised on March 14, 2006