Homework 2 // Due at lecture Fri, Sep 16
Primary contact for this homework: Newsha Ardalani [newsha at cs dot wisc dot edu]
You must do this homework in groups of two. Please write the full name and the student id of each member on every pages and staple multiple pages together.
Problem 1 (4 points)
Find the 2's complement of the following binary numbers.
-
0110 0010
-
0011 1011
-
1001 1101
-
0011 1111
Problem 2 (4 points)
Convert the following 2's complement binary numbers to decimal numbers.
-
0111
-
1101
-
01110
-
111010
Problem 3 (8 points)
Using 1 byte (8 bits) to represent each number, write the binary representations of 28 and -28 in unsigned, sign-magnitude, 1's complement, and 2's complement.
Number | Unsigned | Sign-Magnitude | 1's Complement | 2's Complement |
28 | | | | |
-28 | | | | |
Problem 4 (6 points)
-
Assume that there are exactly 503 occupants in a village. If every person is to be assigned a unique bit pattern, what is the minimum number of bits required to do this?
-
How many more people can be added to the city population without requiring additional bits for each person's unique id?
-
Suppose that for village A, we need 8 bits to represent everyone uniquely. Similarly for village B, we need 9 bits. If both villages are combined into one big village, how many bits are required to represent everyone uniquely?
Problem 5 (4 points)
-
What is the largest positive number one can represent in a 8-bit 2's complement code? Write your result in binary and decimal.
-
What is the greatest magnitude negative number one can represent in a 8-bit 2's complement code? Write your result in binary and decimal.
-
What is the largest positive number one can represent in a 8-bit 1's complement code? Write your result in binary and decimal.
-
What is the greatest magnitude negative number one can represent in a 8-bit 1's complement code? Write your result in binary and decimal.
Problem 6 (2 points)
Compute the followings:
-
NOT(1101) OR NOT(1100)
-
NOT(1000 AND (1100 OR 0101))
Problem 7 (1 points)
Describe what conditions indicate overflow has occurred when two 2's complement numbers are added.
Problem 8 (1 points)
Convert the following bit sequence into hexadecimal
1111101011001110000011111111