ece15_2_2012_6

# ece15_2_2012_6 - Representing negative numbers A negative...

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

1 ECE 15A Fundamentals of Logic Design Lecture 2 Malgorzata Marek-Sadowska Electrical and Computer Engineering Department UCSB 2 Representing negative numbers A negative number is usually indicated by its complement. 2’s complement is the most common. Example: +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 (+) 3 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 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 4 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: 00001110 Convert to decimal: 00001110 2 = 14 10 Put a negative sign in front: -14 b) 00011010 -> 26 5 Example Write 25 in one's complement 0 0 0 1 1 0 0 1 25 Write -25 in one's complement Since the number is negative, complement each bit 1 1 1 0 0 1 1 0 -25 6 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. This is the same as computing 2 - N For -13 00001101 base integer 11110010 1's complement +1 11110011 2's complement 8

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

View Full Document
2 7 Example Write -25 in two's complement format. 0 0 0 1 1 0 0 1 25 1 1 1 0 0 1 1 0 one's complement 1 1 1 0 0 1 1 1 two's complement 8 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 Compute 2’s complement of N convert the binary number to decimal put a minus sign in front 9 Example Convert the following 2's complement representation to decimal: 11100011 Compute 2’s complement: 11100011 -> (1’s complement: 00011100) -> (Add 1: 00011101) (change to decimal) -> 29 -> (put – in front) -> -29 10 Complements Used to simplify the subtraction Arithmetic subtraction (+-A) - (+B) = (+-A) + (-B) (+-A) - (-B) =(+-A) + (+B) 11 Example (1-s complement) Application: 11000000 <=> 1 1 0 0 0 0 0 0 -00100111 + 1
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 04/04/2012 for the course ECE 15A taught by Professor M during the Spring '08 term at UCSB.

### Page1 / 6

ece15_2_2012_6 - Representing negative numbers A negative...

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

View Full Document
Ask a homework question - tutors are online