{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

finalsol

# finalsol - Solution of CSE20 Final Exam Question 1(7.5...

This preview shows pages 1–4. Sign up to view the full content.

Solution of CSE20 Final Exam March 25, 2010 Question 1 (7.5 Points) Show the operation of - 19+( - 4) in a one’s complement binary number system. Assume that each binary number is represented by 10 bits. Solution We first convert each number to its 10-bit one’s complement. We begin by converting the magnitude of each number to a 10-bit binary number: 19 10 = 0000010011 2 4 10 = 0000000100 2 We then flip the bits to get the representation of the negative values: - 19 10 = 1111101100 - 4 10 = 1111111011 We then add the two values: 1111101100 + 1111111011 1111100111 There is a carry out of one, which has to be added back in to the sum: 1111100111 + 1 1111101000 This is the final answer. We can verify the magnitude is correct by flipping the bits again, which yields 10111 2 , which is 23 10 , as expected. 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Grading Policy .5 points were deducted for each conversion error. Small arithmetic errors (for example, dropping a carry) lost 1 point; large arithmetic errors (usually ones that made the answer no longer negative) lost 2 points. Forgetting the end- around carry lost one point. Using fewer than 10 bits lost 4 points. Adding an extra bit lost 1 point. Performing arithmetic with positive numbers lost 4 points. Getting everything right but forgetting to write the final answer lost 1 point. Question 2 (7.5 Points) We have defined and learned the idea of two’s and one’s complements for n-bit binary numbers. Define the corresponding complements using an n-digit system with base 10. Show the arithmetic of - x - y where x = 123 10 and y = 45 10 in the corresponding complement representations using a 5-digit system with base 10. Solution The appropriate complements are nine’s and ten’s complements. We define both and show the arithmetic for each system. To begin with, we’ll define nine’s complement in analogy to one’s comple- ment. Recall that one’s complement for binary (base 2) numbers was defined as - x 2 n - 1 - x, where n is the number of digits. So we define nine’s complement as - x 10 n - 1 - x, again where n is the number of digits. (You’ll see where the “nines” bit comes in soon.) We now convert our operands to 5-digit nine’s complement: - 123 10 10 5 - 1 - 123 = 99999 - 123 = 999876 - 45 10 10 5 - 1 - 45 = 99999 - 45 = 999954 And we add up the operands: 999876 + 999954 999830 There is a carry out which must be added back in to the sum: 999830 + 1 999831 2
This is the final answer for nine’s complement. Now we define ten’s complement in analogy to two’s complement. Recall that two’s complement for binary (base 2) numbers was defined as - x 2 n - x, where n is the number of digits. So we define ten’s complement as - x 10 n - x, again where n is the number of digits. (Note that the ten’s complement is just the nine’s complement plus one! Note also that this is exactly the case for two’s complement, which is just one’s complement plus one.) Again, we convert our operands to 5-digit ten’s complement: - 123 10 10 5 - 123 = 100000 - 123 = 999877 - 45 10 10 5 - 45 = 100000 - 45 = 999955 And, once again, we add the operands: 999877 + 999955 999832 This is the final answer for ten’s complement.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 10

finalsol - Solution of CSE20 Final Exam Question 1(7.5...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online