{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture2_2011_6

lecture2_2011_6 - Representing negative numbers A negative...

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

View Full Document Right Arrow Icon
1 ECE 15A Fundamentals of Logic Design Lecture 2 Malgorzata Marek-Sadowska Electrical and Computer Engineering Department UCSB Representing negative numbers A negative number is usually indicated by its complement. 2’s complement is the most common. Example: 2 +11 : 00001011 -11 : 10001011 (signed magnitude) 11110100 (signed one’s complement) 11110101 (signed two’s complement) Signed 2’s complement has only one representation for 0 (+) One's complement format - 8 bit arithmetic Change the number N to binary, ignoring the sign. Add 0s to the left of the binary number to make a total of 8 bits 3 If the sign is positive, do nothing. If the sign is negative, complement every bit (i.e. change from 0 to 1 or from 1 to 0) In this way we compute (2 -1) - N 8 One's Complement to Decimal Convert the following 1's complement representation to decimal: a) 11110001 Since the sign bit is 1, complement the number: 4 00001110 Convert to decimal: 00001110 2 = 14 10 Put a negative sign in front: -14 b) 00011010 -> 26 Example Write 25 in one's complement 0 0 0 1 1 0 0 1 25 W it 25 i ' l t 5 Write -25 in one's complement Since the number is negative, complement each bit 1 1 1 0 0 1 1 0 -25 Two's complement format - 8 bit arithmetic Most computers today use 2's complement representation for negative numbers. The 2's complement of a negative number N is obtained by adding 1 to the 1's complement. 6 This is the same as computing 2 - N For -13 00001101 base integer 11110010 1's complement +1 11110011 2's complement 8
Background image of page 1

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

View Full Document Right Arrow Icon