Chapter 7 Arithmetic Operations and Circuits 1
7-1 Binary Arithmetic Addition –When the sum exceeds 1, carry a 1 over to the next-more-significant column. –0 + 0 = 0 carry 0 –0 + 1 = 1 carry 0 –1 + 0 = 1 carry 0 –1 + 1 = 0 carry 1 5
Binary Arithmetic Addition –General form A 0 + B 0 = 0 + C out Summation symbol ( ) Carry-out (C out ) 6
Binary Arithmetic –Carry-out is added to the next-more-significant column as a carry-in. 7
Binary Arithmetic Subtraction –0 0 = 0 borrow 0 –0 1 = 1 borrow 1 –1 0 = 1 borrow 0 –1 1 = 0 borrow 0 General form A 0 B 0 = R 0 + B out –Remainder is R 0 –Borrow is B out 8
9
Binary Arithmetic Subtraction –When A 0 borrows from its left, A 0 increases by
Binary Arithmetic Multiplication –Multiply the 2 0 bit of the multiplier times the multiplicand. –Multiply the 2 1 bit of the multiplier times the multiplicand. Shift the result one position to the left. –Repeat step 2 for the 2 2 bit of the multiplier, and for all remaining bits. –Take the sum of the partial products to get the final product. 11
Binary Arithmetic Multiplication –Very similar to multiplying decimal numbers. 12
Binary Arithmetic Division –The same as decimal division. –This process is illustrated in Example
14 Example 7-4
14 Example 7-4 (Continued)
7-2 Two’s-Complement Representation Both positive and negative numbers can be represented Binary subtraction is simplified Groups of eight Most significant bit (MSB) signifies positive or negative 15
Two’s-Complement Representation Sign bit –0 for positive –1 for negative Range of positive numbers (8-bit) – to (0 to 127) –Maximum positive number: 2 N-1 -1 Range of negative numbers (8-bit) – to (-1 to -128) –Minimum negative number: -2 N-1 16
Decimal-to-Two’s-Complement Conversion If a number is positive, –the two’s complement number is the true binary equivalent of the decimal number. If a number is negative: –Complement each bit (one’s complement) –Add 1 to the one’s complement The sign bit will always end up a 1. 18
Two’s-Complement Representation 18
Two’s-Complement-to-Decimal Conversion If the number is positive (sign bit = 0), convert directly If the number is negative: –Complement the entire two’s-complement number –Add 1 –Do the regular b-to-d conversion to get the decimal numeric value –Result will be a negative number 19
Discussion Point Convert the following numbers to two’s- complement form: Convert the following two’s-complement number to decimal:
7-3 Two’s-Complement Arithmetic Addition –Regular binary addition Subtraction –Convert number to be subtracted to a negative two’s-complement number –Regular binary addition –Carry out of the MSB is ignored 21
Discussion Point Add the following numbers using two’s complement arithmetic: – 7 21 – – 96 22