Presentation is loading. Please wait.

Presentation is loading. Please wait.

Summer 2012ETE 204 - Digital Electronics1 Binary Arithmetic of Signed Binary Numbers.

Similar presentations


Presentation on theme: "Summer 2012ETE 204 - Digital Electronics1 Binary Arithmetic of Signed Binary Numbers."— Presentation transcript:

1 Summer 2012ETE 204 - Digital Electronics1 Binary Arithmetic of Signed Binary Numbers

2 2 2's Complement Addition Addition of n-bit signed binary numbers is straightforward using the 2's Complement number system. Addition is carried out in the same way as for n-bit positive numbers. Carry from the sign bit (leftmost bit) is ignored. Overflow occurs if the correct result (including the sign bit) cannot be represented in n bits. Summer 2012ETE 204 - Digital Electronics

3 3 2's Complement Addition: Example Using 2's Complement addition and 8-bit representation, add the following numbers: -47 + 83 Did overflow occur? Summer 2012ETE 204 - Digital Electronics

4 4 2's Complement Addition: Example Using 2's Complement addition and 8-bit representation, add the following numbers: -32 + -105 Did overflow occur? Summer 2012ETE 204 - Digital Electronics

5 5 2's Complement Addition: Example Using 2's Complement addition and 8-bit representation, add the following numbers: 19 + 52 Did overflow occur? Summer 2012ETE 204 - Digital Electronics

6 6 2's Complement Addition: Example Using 2's Complement addition and 8-bit representation, add the following numbers: 64 + 78 Did overflow occur? Summer 2012ETE 204 - Digital Electronics

7 7 2's Complement Subtraction Subtraction can be implemented using addition.  Determine the 2's Complement representation for the negative number -B.  Use 2's Complement addition to add A and -B. A – B = A + (-B) Summer 2012ETE 204 - Digital Electronics

8 8 2's Complement Subtraction: Example Subtract the following numbers, using 2's Complement addition and 8-bit representation: 64 – 78 Did overflow occur? Summer 2012ETE 204 - Digital Electronics

9 9 2's Complement Subtraction: Example Subtract the following numbers, using 2's Complement addition and 8-bit representation: -35 – 62 Did overflow occur? Summer 2012ETE 204 - Digital Electronics

10 10 2's Complement Subtraction: Example Subtract the following numbers, using 2's Complement addition and 8-bit representation: 14 – (-59) Did overflow occur? Summer 2012ETE 204 - Digital Electronics

11 11 2's Complement Subtraction: Example Subtract the following numbers, using binary subtraction and 8-bit representation: 27 – 45 Can this subtraction be carried out? Summer 2012ETE 204 - Digital Electronics

12 12 1's Complement Addition Similar to 2's Complement Addition of n-bit signed binary numbers. However, rather than ignore the carry-out from the sign (leftmost) bit, add it to the least significant bit (LSB) of the n-bit sum.  Known as the end-around carry. Summer 2012ETE 204 - Digital Electronics

13 13 1's Complement Addition: Example Using 1's Complement addition and 8-bit representation, add the following numbers: -31 + -84 Did overflow occur? Summer 2012ETE 204 - Digital Electronics

14 14 1's Complement Addition: Example Using 1's Complement addition and 8-bit representation, add the following numbers: 52 + 73 Did overflow occur? Summer 2012ETE 204 - Digital Electronics

15 15 Overflow The general rule for detecting overflow when performing 2's Complement or 1's Complement Addition:  An overflow occurs when the addition of two positive numbers results in a negative number.  An overflow occurs when the addition of two negative numbers results in a positive number.  Overflow cannot occur when adding a positive number to a negative number. Summer 2012ETE 204 - Digital Electronics

16 16 Binary Codes Summer 2012ETE 204 - Digital Electronics

17 17 Binary Codes Weighted Codes  Each position in the code has a specific weight  Decimal value of code can be determined Unweighted Codes  Positions of code do not have a specific weight  Decimal value assigned to each code Summer 2012ETE 204 - Digital Electronics

18 18 Binary Codes n-bit Weighted Codes  Code:a n-1 a n-2 a n-3...a 1 a 0  Weights:w n-1, w n-2, w n-3,..., w 1, w 0  Decimal Value:a n-1 x w n-1 + a n-2 x w n-2 + … + a 1 x w 1 + a 0 x w 0 4-bit Weighted Code  Code:a 3 a 2 a 1 a 0 Summer 2012ETE 204 - Digital Electronics

19 19 Binary Codes Examples of 4-bit weighted codes  8-4-2-1 4 bits → 16 code words Only 10 code words required to represent decimal digits  6-3-1-1 4 bits → 16 code words  Excess-3 (obtained from 8-4-2-1) 4 bits → 16 code words Summer 2012ETE 204 - Digital Electronics

20 20 Binary Codes Examples of unweighted codes  2-out-of-5 Code Exactly 2 of the 5 bits are “1” for a valid code word. 10 valid code words.  Gray Code Code values for successive decimal digits differ in exactly one bit. 4 bits → 16 code words. Summer 2012ETE 204 - Digital Electronics

21 21 Binary Codes Summer 2012ETE 204 - Digital Electronics

22 22 Binary Coded Decimal (BCD) 4-bit binary number used to represent each decimal digit. Weighted code:8-4-2-1 Binary values 0000 … 1001 used to represent decimal values 0 … 9. Binary values 1010 … 1111 not used. Very different from binary representation. Summer 2012ETE 204 - Digital Electronics

23 23 Binary Coded Decimal In BCD, each decimal digit is replaced by its binary equivalent value. Example: Binary:937.25 10 = 1110101001.01 2 Summer 2012ETE 204 - Digital Electronics

24 24 ASCII American Standard Code for Information Interchange Common code for the storage and transfer of alphanumeric characters. 7-bit Weighted Code  Can represent 128 characters Used to represent letters, numbers, and other characters Any word or number can be represented using its ASCII code. Summer 2012ETE 204 - Digital Electronics

25 25 ASCII Code (incomplete) Summer 2012ETE 204 - Digital Electronics

26 26 Questions? Summer 2012ETE 204 - Digital Electronics


Download ppt "Summer 2012ETE 204 - Digital Electronics1 Binary Arithmetic of Signed Binary Numbers."

Similar presentations


Ads by Google