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.
- 123.45
- 1000.50
- BAD.CAB
- DA7.35C
Strategy
- Start from the MSD to LSD.
- Replace each hexadecimal digit with corresponding 4 binary string.
Problem 2
Question
(Number conversion) Find the decimal equivalents of the following radix-7 numbers.
- 606
- 123
- 6650
- 345.6
Strategy
- Use the definition of the positional number: the value of a given number is equivalent to the weighted sum of all its digits.
- That is, D = ...d2 * (7*7) + d1 * (7) + d0 * (1).
- Calculate the expression.
Problem 3
Question
(Addition rules) Add the following numbers without converting them to decimal representations.
- 01110(binary) and 110011(binary)
- 98A(base 12) and 234 (base 12)
- ABC(Hexadecimal) and A78(Hexadecimal)
Strategy
- i = 0; C0 = 0.
- If (i >= m) then goto 5.
- C(i + 1), s(i) = x(i) + y(i) + C(i).
- i = i+1; Goto 2.
- 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.
- 101110-10001
- 111111-11110
- 11110-1001
- 100001-10001
Strategy
- (Get complement of subtrahend) Change subtrahend's digit '0 ' to '1', '1' digit to '0', and add 1.
- Use the strategy of 2.11 to add complement of subtrahend and minuend.
- If the carries into and out of the sign bit are different, it is overflow.
- 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.
- 011011 * 0011
Strategy
- PP = 0 (PP keep the same number of digit with multiplicand);
i = 0.
- Extend one "MSD" digit for PP.
- SMD = ('i'th power of 2) * MD;
extend one "MSD" digit for SMD;
if (bi = 0) then goto 5.
- PP = PP + SMD;
ignore the carry beyond "MSD".
- i = i + 1.
- If (i < m - 1) then goto 2.
- If (bm - 1 = 0) goto 11.
- Extend a "MSD" digit for PP.
- 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.
- PP = PP + SMD;
Ignore the carry beyond "MSD".
- Product == PP.
Note: 'm' is number of digit of multiplier.
Reference: section 2.7
Problem 6
Question
(Division rules) Divide the following binary numbers.
- 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:
- Sign-magnitude binary numbers.
Strategy
Reference: section 2.8
Problem 8
Question
(Floating-point algorithms) Define the procedure for:
- adding
- multiplying
Strategy
Reference: section 2.9