Computer Sciences Dept.

CS/ECE 252 Introduction to Computer Engineering

Fall 2012 Section 3
Instructor Guri Sohi
TAs Pradip Vallathol and Junaid Khalid

URL: http://www.cs.wisc.edu/~sohi/cs252/Fall2012/

Homework 2 [Due at lecture on Wed, Sep 19]

Primary contact for this homework: Pradip Vallathol [pradip16 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 page and staple multiple pages together.

Problem 1 (8 points)

Convert the following 2's complement binary numbers to decimal and hexadecimal representations. [The hexadecimal representation when converted into it corresponding binary string should represent the same 2's complement binary number as mentioned in the corresponding part. In other words, if you have to extend the 2's complement binary number before converting it into hexadecimal representation, you have to do so without changing its value.]

  1. 1001
  2. 011101
  3. 010010110
  4. 1101011001001

Problem 2 (6 points)

  1. If I use an unconventional representation in which a decimal number is denoted by converting each digit into its binary form, how many bits would be necessary to represent the decimal number 318. [My representation is unambiguous, i.e., if I am given a binary string, there is one, and only one, decimal number that it would represent. If I had used minimum number of bits to represent each digit, my representation would become ambiguous. For example, if I had a binary string "1001", and I had used minimum number or bits for each digit, it could mean either 41 or 21 or 9. So now you have to reason how many bits I would have to allocate to each digit, in my representation, so that I have a unique representation of decimal numbers.]
  2. What is the minimum number of bits I would have required if I had represented decimal number 318 in binary form?
  3. Is there a number that can be represented by using the same number of bits in my representation and in binary form (with minimum number of bits)?

Problem 3 (4 points)

The following binary numbers are 4-bit 2's complement binary numbers. Which of the following operations generate overflow? Justify your answers by translating the operands and results into decimal.

  1. 0101 + 0010
  2. 0111 - 1011
  3. 1011 + 1101
  4. 1010 - 0110

Problem 4 (2 points)

Compute the followings:

  1. NOT(1101) OR (0110 AND 0111)
  2. (1010 OR 0010) OR NOT(0010 AND 0110))

Problem 5 (4 points)

  1. What is the largest positive number one can represent in a 6-bit 2's complement code? Write your result in binary and decimal.
  2. What is the greatest magnitude negative number one can represent in a 6-bit 2's complement code? Write your result in binary and decimal.
  3. What is the largest positive number one can represent in a 6-bit 1's complement code? Write your result in binary and decimal.
  4. What is the greatest magnitude negative number one can represent in a 6-bit 1's complement code? Write your result in binary and decimal.

Problem 6 (4 points)

Write the decimal equivalents for these IEEE floating point numbers.

  1. 1 01111101 10000000000000000000000
  2. 0 10000010 01100000000000000000000

Problem 7 (2 points)

Why is sign-extension important when adding binary numbers with representations of different lengths? Explain with the help of an example.

 
Computer Sciences | UW Home