Presentation is loading. Please wait.

Presentation is loading. Please wait.

Complement Theory 1’s and, 2’s complement operation

Similar presentations


Presentation on theme: "Complement Theory 1’s and, 2’s complement operation"— Presentation transcript:

1 Complement Theory 1’s and, 2’s complement operation 9’s and, 10’s complement operation (r-1)’s and r’s complement Binary Codes Weighted Codes Un-Weighted Codes Error Processing Codes Alphanumeric codes.

2 Example 1 Get 1’s complement of 50
Complement Theory Example 1 Get 1’s complement of 50 50 = Complement Digits 

3 1’s Complement Theory Example 2 : Subtract 1010 from 1111 using 1’s complement theory. (Small negative) + 1’s complement 1] + =(5) Carry “1” means the answer is positive . 

4 1’s Complement Theory Example 3 : Subtract 1010 from 1000 using 1’s complement theory. (Large negative) + 1’s complement 0] Carry “0” means the answer is negative and available in 1’s complement form. = (2)

5 2’s Complement Arithmetic
How to get 2’s complement form Arithmetic operation using 2’s complement theory

6 2’s Complement Arithmetic (How to get 2’s complement form..?)
Example 1 5 = Complement Digits  Add 1 +1 -5 = Example 2 -13 = Complement Digits  Add 1 +1 13 =

7 2’s Complement Arithmetic (Method)
Read both the operands Negative operand(s) (if any) is converted into 2’s complement form Add both the numbers If carry is generated (i.e. =1) then the resultant number is positive and in original form If carry is not generated(when we have negative operand) then the carry is assumed =0. If carry is not generated (with both the operand positive) then the answer is Positive. Carry zero means the resultant number is negative and in a 2’s complement form. Convert the 2’s complement form into the original form.

8 2's Complement Arithmetic
Digital Electronics  Lesson 2.4 – Specific Comb Circuit & Misc Topics POS + NEG → POS Answer Take the 2’s complement of the negative number and use regular binary addition. 9 + (-5) 4  +  Last Bit = 1: Answer is Positive Disregard 9th Bit This example shows the addition of one positive and one negative numbers. Note that this is done in the same way as subtracting a positive number from a positive number. In this case, the answer is positive.  +1 2’s Complement Process Project Lead The Way, Inc. Copyright 2009

9 2's Complement Arithmetic
Digital Electronics  Lesson 2.4 – Specific Comb Circuit & Misc Topics POS + NEG → NEG Answer Take the 2’s complement of the negative number and use regular binary addition. (-9) + 5 -4  +  Last Bit = 0: Answer is Negative . Discard the last bit This slide demonstrates the addition of one positive and one negative number. Again, this is is the same a subtracting a positive number from a positive number. In this case the answer happens to be negative.  +1 To Check: Perform 2’s Complement On Answer  +1 2’s Complement Process Project Lead The Way, Inc. Copyright 2009

10 Verify the logic using following combinations:
1: (10) –(01) 2: (10) –(02) 3: (10) –(05) 4: (10) –(08) 5: (10) –(09) 6: (10) –(10) 7: (210) –(08) 8: (120) –(55) 9: (52) –(18)

11 2’s Complement Arithmetic (Examples)
A+B A B 2’s of B Addition Ans A=10 B=-1 CY =1 So ans is +ve +9 B=-2 CY =1 So ans is +ve +8 B=-5 CY =1 So ans is +ve +5 B=-8 CY =1 So ans is +ve +2 B=-9 CY =1 So ans is +ve +1 B=-10 CY =1 So ans is +ve +0

12 2’s Complement Arithmetic (Examples)
Example: Perform 2’s complement arithmetic for (30)-(50) using 1: 6-bit number system 2: 8-bit number system

13 Example: Perform 2’s complement arithmetic for (30)-(50) using:
1: 6-bit number system : 8-bit number system (30)= (-50)= ’s complement (30)= (-50)= ’s complement Add both the numbers Add both the numbers Carry =0 means number is negative and in 2’s compl form = -20 Carry =0 means number is negative and in 2’s compl form = -20

14 (r-1)’s and r’s complement
Example of r=9 9’ and 10’s complement

15 How to get (r-1)’s complement of decimal number…?
Say r =10 How do we get (r-1)’s complement …? (r-1)′s i.e. 9’s complement of decimal number can be obtained by ((10n - 1)-number) where n represents the number of digits in given number. Example 1: Find 9’s complement of   (1234)10 9′s complement = = = 8765 How do we get (r)’s complement …? r's i.e. 10’s complement can be obtained by (10n – number) Example 2: Find 10′s complement = = 8766. Now that we have learned to convert decimal number to its 9′s & 10′s complement, we will move to subtraction using them. Remember always the number to be subtracted or negative number is converted to 9′s or 10′s complement.

16 9’s Complement Arithmetic
Example 1: Get 9’s complement of following numbers (19)10 , (146)10, (4397)10

17 9’s Complement Arithmetic
Example 1: Perform subtraction using 9’s complement on the data set given below. a: , b: c: d: 49-84 We will ADD 93 and 18 9 3 + 1 8 A carry is generated means answer is +ve ADD the carry back to the sum “11”. 1 1 + 1 1 2 06 is negative number, We will get 9’s complement of 06 9 9 - 0 6 9 3

18 9’s Complement Arithmetic
Example 2: Perform 9’s complement subtraction on the data set given below. a: , b: c: d: 49-84 We will ADD 76 and 39 7 6 + 3 9 A carry is generated . ADD the carry back to the sum “15”. 1 5 + 1 1 6 23 is negative number, We will get 9’s complement of 23 9 9 - 2 3 7 6

19 9’s Complement Arithmetic
Example 3: Perform 9’s complement subtraction on the data set given below. a: , b: c: d: 49-84 We will ADD 50 and 34 5 0 + 3 4 0 8 4 A carry is not generated that means answer is Negative. Get 9’s complement of 84 9 9 _ 8 4 1 5 Answer is -15 49 is negative number, We will get 9’s complement of 49 9 9 - 4 9 5 0

20 9’s Complement Arithmetic
Example 4: Perform 9’s complement subtraction on the data set given below. a: , b: c: d: 49-84 We will ADD 15 and 49 4 9 + 1 5 0 6 4 A carry is not generated that means answer is Negative. Get 9’s complement of 64 9 9 _ 6 4 3 5 Answer is -35 84 is negative number, We will get 9’s complement of 84 9 9 - 8 4 1 5

21 10’s Complement Arithmetic
Example 1: Perform 10’s complement subtraction on the data set given below. a: , b: c: We will ADD 91 and 24 2 4 + 9 1 1 1 5 09 is negative number, We will get 10’s complement of 09 9 9 - 0 9 9 0 9 1 A carry is generated that means answer is Positive. Answer is +15

22 10’s Complement Arithmetic
Example 2: Perform 10’s complement subtraction on the data set given below. a: , b: c: We will ADD 68 and 69 6 8 + 6 9 1 3 7 32 is negative number, We will get 10’s complement of 32 9 9 - 3 2 6 7 6 8 A carry is generated that means answer is Positive. Answer is +37

23 10’s Complement Arithmetic
Example 3: Perform 10’s complement subtraction on the data set given below. a: , b: c: We will ADD 653 and 265 653 + 265 0 918 347 is negative number, We will get 10’s complement of 347 9 9 9 6 5 2 6 5 3 A carry is not generated that means answer is Negative and in 10’s complement form. Get 10’s complement form of 918 9 9 9 -9 1 8 0 8 1 +0 0 1 Ans = -82

24 Binary Codes Weighted Codes (8421, 5421)
Non Weighted codes (Excess-3 , BCD, Gray) Error Processing Codes (PARITY Bits, Hamming Codes) Alphanumeric Codes (ASCII, EBCDIC)

25 1: Weighted Codes: Weighted binary codes are those binary codes which obey the positional weight principle. Each position of the number represents a specific weight. 5 1 4 2 7 12 15

26 2: Non-Weighted Codes: Non-weighted coding method that alters just one bit in a binary number when moving from one decimal number to the next. 2.1: Excess-3 is a non-weighted coding method. With excess-3, we add 3 to a decimal number before converting it to binary. Example: (0001)2 = (0100)Excess-3 (0010)2 = (0101)Excess-3 2.2: BCD (Binary Coded Decimals) is a non-weighted coding method. Individual decimal digits are converted into equivalent binary bits. Example: (321)2 = ( )BCD (000)2 = ( )BCD (80)2 = ( )BCD (00)2 = ( )BCD

27 2: Non-Weighted Codes: Non-weighted coding method that alters just one bit in a binary number when moving from one decimal number to the next. 2.3: Gray Codes: It is also called as Reflected Binary codes. It is generated via getting mirror image of given data. Example : 4 bit Gray codes. 1 1 1 1 1 1 0 1 1 0 1 0 0

28 2: Non-Weighted Codes: Comparing Gray codes and Binary Codes
Find out the difference between both the codes..?

29 2: Non-Weighted Codes: Converting Binary Codes to Gray codes Method:
Copy MSB of Binary code to MSB of Gray code. Add MSB of Binary with Next MSB of Binary to get next Gray code. Discard the carry Repeat the same process till we get the LSB Example: Convert (0001)2 into Gray code. 0+0= 0 0+0= 0 0+1= 1 1

30 2: Non-Weighted Codes: Converting Binary Codes to Gray codes Method:
Copy MSB of Binary code to MSB of Gray code. Add MSB of Binary with Next MSB of Binary to get next Gray code. Discard the carry Repeat the same process till we get the LSB Example: Convert (1011)2 into Gray code. 1+0= 1 0+1= 1 1+1= 0 1 1 1

31 2: Non-Weighted Codes: Converting Gray Codes to Binary codes Method:
Copy MSB of Gray code to MSB of Binary code. If next bit of Gray code is “1”, then invert the present binary bit as next bit. If next bit of Gray code is “0” then copy the present binary bit as next bit. Example: Convert (1011) gray into Binary code. 1 1 1

32


Download ppt "Complement Theory 1’s and, 2’s complement operation"

Similar presentations


Ads by Google