cse20_quiz1-2-3

cse20_quiz1-2-3 - 6 th bit is ignored, and the answer is 1....

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Quiz 1) Given x = 9, n = 5 Represent: a) x in binary b) -x in 1's complement c) -x in 2's complement a) 9 in binary using 5 bits = 01001 b) -9 in 1's complemet = 10110 ( flip the bits from part a) c) - 9 in 2's complement = 10111 ( add 1 to 1's complement, i.e. result from part b) Quiz 2) Given x = 5, y = 4, n = 5 Calculate : a) x+y b) x-y c ) -x +y d) -x -y First, let us represent x, y, -x, -y in 2's complement. x = 5 = 00101 , y = 4 = 00100 , -x = -5 = 11011 ( flip the bits + 1 = 11010 + 1 = 11011), - y = 11100 ( flip the bits + 1 = 11011 +1 = 11100) Now, let us do the asked calculation a) x + y 00101 (5) + 00100 (4) -------------- 01001 (9) b)x – y = x + (-y) 00101 (5) + 11100 (-4) --------------- 100001 (1) In this case, since we have an extra bit in the sum ( i.e. 6 bits instead of 5) the
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 6 th bit is ignored, and the answer is 1. c) x + y = (-x) + y 11011 (-5) + 00100 (4)---------------11111 (-1) d) - x - y = (-x) + (-y) 11011 (-5) + 11100 (-4)-----------------110111 (-9) Again, ignore the 6 th bit and the result is -9 in 2's complement. Quiz 3) A subtractor has (x,y, b in ) as inputs and (d, b out ) as outputs. Write the truth table of the subtractor. Id Inputs Outputs x y b in d b out 1 1 1 1 2 1 1 1 3 1 1 1 4 1 1 5 1 1 6 1 1 7 1 1 1 1 1 To fill out the truth table, first fill up the d column (i.e. difference) based on the given inputs (x, y, b in ) . Then use the formula x- y b in = d 2b out to calculate b out ....
View Full Document

This note was uploaded on 12/11/2011 for the course CSE 20 taught by Professor Foster during the Fall '08 term at UCSD.

Page1 / 2

cse20_quiz1-2-3 - 6 th bit is ignored, and the answer is 1....

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online