EECS 284 Winter 2000
Homework 1 Solutions
Problem 1
-
Minimum number of bits required = 6, since 25 = 32 <
49 < 64 = 26
-
64 – 49 = 15 more students can be added
Problem 2
-
Largest positive number in 16-bit two’s complement is 0111 1111 1111
1111 which corresponds to 215 - 1 = 32767.
-
The greatest magnitude negative number that can be represented in 16-bit
two’s complement is 1000 0000 0000 0000 which corresponds to –
(215 ) = – 32768.
-
Largest positive number in n-bit two’s complement code is 2n-1
- 1
-
Greatest magnitude negative number in n-bit two’s complement code –
(2n-1 )
Problem 3
-
01011010 + 01110110 = 11010000 = 0xD0 ; no overflow
-
11010011 + 00110111 = 00001010 = 0x0A ; overflow
-
01110111 + 01111100 = 11110011 = 0xF3 ; no overflow
-
01100110 + 10101010 = 00010000 = 0x10 ; overflow
Problem 4
-
NOT(NOT(1001)) AND NOT(1101)
Þ NOT(0110) AND 0010
Þ 1001 AND 0010
Þ 0000 = x0
-
(NOT(1100) AND NOT(1001)) OR 0101
Þ (0011 AND 0110) OR 0101
Þ 0010 OR 0101
Þ 0111 = x7
-
NOT (1101 AND NOT(0001))
Þ NOT (1101 AND 1110)
Þ NOT (1100)
Þ 0011 = x3
-
NOT(((0101 OR 1100) OR 0001) AND 1001)
Þ NOT((1101 OR 0001) AND 1001)
Þ NOT(1101 AND 1001)
Þ NOT(1001)
Þ 0110 = x6
Problem 5
Hex
|
Unsigned
|
Sign-magnitude
|
One’s complement
|
Two’s complement
|
XFABD
|
64189
|
-31421
|
-1346
|
-1347
|
x1001
|
4097
|
4097
|
4097
|
4097
|
x20a1
|
8353
|
8353
|
8353
|
8353
|
xEA00
|
59904
|
-27136
|
-5361
|
-5632
|
Problem 6
Addition
|
Unsigned
|
Overflow
|
Two’s complement
|
Overflow
|
x057E + x26CD
|
x2C4B
|
No
|
x2C4B
|
No
|
xAC01 + xE1BD
|
x0DBE
|
Yes
|
x0DBE
|
No
|
x6CA1 + x5B9D
|
xCD3E
|
No
|
xCD3E
|
Yes
|
xABCD + x099E
|
xB56B
|
No
|
xB56B
|
No
|
Problem 7
A
|
B
|
|
Q1
|
Q2
|
Q3
|
0
|
0
|
|
1
|
0
|
1
|
0
|
1
|
|
0
|
1
|
0
|
1
|
0
|
|
0
|
0
|
0
|
1
|
1
|
|
0
|
0
|
1
|
Problem 8
X
|
Y
|
Z
|
|
Q1
|
Q2
|
0
|
0
|
0
|
|
0
|
0
|
0
|
0
|
1
|
|
0
|
0
|
0
|
1
|
0
|
|
0
|
0
|
0
|
1
|
1
|
|
0
|
0
|
1
|
0
|
0
|
|
0
|
0
|
1
|
0
|
1
|
|
0
|
0
|
1
|
1
|
0
|
|
0
|
0
|
1
|
1
|
1
|
|
1
|
1
|
Problem 9