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 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 DocumentRight Arrow Icon
2 Example Write -25 in two's complement format. 0 0 0 1 1 0 0 1 25 11100110 ne 'sc mplemen 7 1 1 1 0 0 1 1 0 one's complement 1 1 1 0 0 1 1 1 two's complement Two's Complement to Decimal If the sign bit is 0, convert the binary number to decimal. If the sign bit of N is 1 8 Compute 2’s complement of N convert the binary number to decimal put a minus sign in front Example Convert the following 2's complement representation to decimal: 11100011 Compute 2’s complement: 9 11100011 -> (1’s complement: 00011100) -> (Add 1: 00011101) (change to decimal) -> 29 -> (put – in front) -> -29 Complements Used to simplify the subtraction Arithmetic subtraction 10 (+-A) - (+B) = (+-A) + (-B) (+-A) - (-B) =(+-A) + (+B) Example (1-s complement) Application: 11000000 <=> 1 1 0 0 0 0 0 0 -00100111 + 1 1 0 1 1 0 0 0 1 100110 00 ( one’s complement) 11 + 1
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/26/2011 for the course ECE 15A taught by Professor M during the Winter '08 term at UCSB.

Page1 / 6

lecture2_2011_6 - Representing negative numbers A negative...

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

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