EECS 31/CSE 31/ICS 151 Homework 1 Questions with Strategies

View Questions Only
View Questions with Solutions

Problem 1

Question

(Number conversion) Give the binary equivalents of the following hexadecimal numbers.

  1. 123.45
  2. 1000.50
  3. BAD.CAB
  4. DA7.35C

Strategy

  1. Start from the MSD to LSD.
  2. Replace each hexadecimal digit with corresponding 4 binary string.

Problem 2

Question

(Number conversion) Find the decimal equivalents of the following radix-7 numbers.

  1. 606
  2. 123
  3. 6650
  4. 345.6

Strategy

  1. Use the definition of the positional number: the value of a given number is equivalent to the weighted sum of all its digits.
  2. That is, D = ...d2 * (7*7) + d1 * (7) + d0 * (1).
  3. Calculate the expression.

Problem 3

Question

(Addition rules) Add the following numbers without converting them to decimal representations.

  1. 01110(binary) and 110011(binary)
  2. 98A(base 12) and 234 (base 12)
  3. ABC(Hexadecimal) and A78(Hexadecimal)

Strategy

  1. i = 0; C0 = 0.
  2. If (i >= m) then goto 5.
  3. C(i + 1), s(i) = x(i) + y(i) + C(i).
  4. i = i+1; Goto 2.
  5. Done.

Note: variable 'i' is position number, variable 'm' is number of digit, C0 is carry in position 0;

Reference: section 2.4, Figure 2.3

Problem 4

Question

(Subtraction rules) Perform binary subtraction by taking the two's complement of the subtrahend.

  1. 101110-10001
  2. 111111-11110
  3. 11110-1001
  4. 100001-10001

Strategy

  1. (Get complement of subtrahend) Change subtrahend's digit '0 ' to '1', '1' digit to '0', and add 1.
  2. Use the strategy of 2.11 to add complement of subtrahend and minuend.
  3. If the carries into and out of the sign bit are different, it is overflow.
  4. Ignore the carry beyond the sign bit.

Note: the numbers in the questions are unsigned numbers.

Reference: section 2.6

Problem 5

Question

(Multiplication rules) Perform binary multiplication with the following two's complement numbers.

  1. 011011 * 0011

Strategy

  1. PP = 0 (PP keep the same number of digit with multiplicand);
    i = 0.
  2. Extend one "MSD" digit for PP.
  3. SMD = ('i'th power of 2) * MD;
    extend one "MSD" digit for SMD;
    if (bi = 0) then goto 5.
  4. PP = PP + SMD;
    ignore the carry beyond "MSD".
  5. i = i + 1.
  6. If (i < m - 1) then goto 2.
  7. If (bm - 1 = 0) goto 11.
  8. Extend a "MSD" digit for PP.
  9. SMD = ('m-1'th power of 2) * MD;
    Extend a "MSD" digit for SMD;
    SMD = change SMD's digit '0 ' to '1', '1' digit to '0', and add 1.
  10. PP = PP + SMD;
    Ignore the carry beyond "MSD".
  11. Product == PP.

Note: 'm' is number of digit of multiplier.

Reference: section 2.7

Problem 6

Question

(Division rules) Divide the following binary numbers.

  1. 11011/1001

Strategy

Reference: section 2.8 and solution of 2.20(a).

Problem 7

Question

(Division algorithms) Define the procedure and draw the flowchart for the division of:

  1. Sign-magnitude binary numbers.

Strategy

Reference: section 2.8

Problem 8

Question

(Floating-point algorithms) Define the procedure for:

  1. adding
  2. multiplying

Strategy

Reference: section 2.9