This preview shows pages 1–4. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Solution of CSE20 Final Exam March 25, 2010 Question 1 (7.5 Points) Show the operation of 19+( 4) in a ones complement binary number system. Assume that each binary number is represented by 10 bits. Solution We first convert each number to its 10bit ones complement. We begin by converting the magnitude of each number to a 10bit 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 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 twos and ones complements for nbit binary numbers. Define the corresponding complements using an ndigit 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 5digit system with base 10. Solution The appropriate complements are nines and tens complements. We define both and show the arithmetic for each system. To begin with, well define nines complement in analogy to ones comple ment. Recall that ones complement for binary (base 2) numbers was defined as x 2 n 1 x, where n is the number of digits. So we define nines complement as x 10 n 1 x, again where n is the number of digits. (Youll see where the nines bit comes in soon.) We now convert our operands to 5digit nines 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 nines complement. Now we define tens complement in analogy to twos complement. Recall that twos complement for binary (base 2) numbers was defined as x 2 n x, where n is the number of digits. So we define tens complement as x 10 n x, again where n is the number of digits. (Note that the tens complement is just the nines complement plus one! Note also that this is exactly the case for twos complement, which is just ones complement plus one.) Again, we convert our operands to 5digit tens complement: 123...
View
Full
Document
This note was uploaded on 06/12/2011 for the course CS 1 taught by Professor Staff during the Fall '08 term at Cornell University (Engineering School).
 Fall '08
 STAFF

Click to edit the document details