Binary subtraction using 1’s and 2’s complement method
How to find 1’s Complement of given number 1’s complement of a number is found by changing all 1’s to 0’s and all 0’s to 1’s. Ex: 1’s complement of a number 10111 is = 01000 Solve---- Find 1’s complement of 11010 = 00101 101101= 010010 1010= 0101 1111=0000 1011001=0100110
How to find 2’s Complement of given number The 2’s complement of a number is obtained by adding 1 to the LSB of 1’s complement of that number 2’s complement = 1’s complement + 1 Ex: obtain 2’s complement of a number (10110010) 2 Solution:
Subtraction using 1 s complement A) For subtracting a smaller number from a larger number, the 1 s complement method is as follows: 1. Determine the 1 s complement of the smaller number. 2. Add the 1 s complement to the larger number. 3. Remove the final carry and add it to the result. This is called the end-around carry.
Binary subtraction using 1’s complement method To perform subtraction (A) 2 - (B) 2 Step 1: convert number to be subtracted (B) 2 to its 1’s complement. Step 2: Add first number (A) 2 and 1’s complement of (B) 2 using rules of binary addition. Step 3: if final carry is 1 then add it to the result of addition obtained in step 2 to get final result. **If final carry in step 2 is 1 then result obtained in step 2 is Positive and in its true form no conversion required. Step 4: if final carry in step 2 is 0 then result obtained in step 2 is negative and in 1’s complement form. So convert it to its true form.
Binary subtraction using 1’s complement 10---------------------------------- 10 -3 - 11-----1’complement of 11 +00 --- ----- -1 10 result 1’s complement of result 01 final result carry 0 so result sign is negative
Binary subtraction using 1’s complement 9 1001 1001 15 1111 1’s complement +0000 ------- ------- -6 1001 1’s complement of result 0110 ---6 carry is 0 so result sign is negative
Binary Subtraction Questions Using 1’s Complement Question 1: (110101) 2 – (100101) 2 Solution: (1 1 0 1 0 1) 2 = 53 10------- minuend. (1 0 0 1 0 1) 2 = 37 10 – subtrahend Now take the 1’s complement of the subtrahend and add with minuend. 1 carry 1 1 0 1 0 1 (+) 0 1 1 0 1 0 —————— 0 0 1 1 1 1 + 1 carry —————— 0 1 0 0 0 0 Therefore, the solution is 010000 (010000) 2 = 16 10 1
Binary Subtraction Questions Using 1’s Complement Question 2: (101011) 2 – (111001) 2 43-57= -14 Solution: Take 1’s complement of the subtrahend 1 1 1 1 0 1 0 1 1 (+) 0 0 0 1 1 0 (1’s complement) —————— 1 1 0 0 0 1 Now take the 1’s complement of the resultant since it does not carry 1 The resultant becomes 0 0 1 1 1 0 Now, add the negative sign to the resultant value Therefore the solution is – (001110) 2 .
Binary subtraction using 2’s complement method To perform subtraction (A) 2 - (B) 2 Step 1: convert number to be subtracted (B) 2 to its 2’s complement. Step 2: Add first number (A) 2 and 2’s complement of (B) 2 using rules of binary addition. Step 3: if final carry is 1 then the result Positive and in its true form no conversion required. Step 4: if final carry in step 2 is 0 then result obtained in step 2 is negative and in 2’s complement form. So convert it to its true form. ** Carry always be discarded.
Binary subtraction using 2’s complement 5 101 -7 111 1’s comple .---000 ---- + 1 -2 ------ 2’s complement 001 +101 ------- result 110 1’s complement 001 + 1 -------- 2’s complement 010 final result Carry is 0 so result is negative
Multiplication (1 of 3) Decimal (just for fun) 35 x 105 175 000 35 3675
Multiplication Binary, two 1-bit values A B A B 1 1 1 1 1
Example Binary Multiplication A = 9 10 = 1001 2 A 3 A 2 A 1 A B = 8 10 = 1000 2 B 3 B 2 B 1 B 1001 × 1000 ------------------ 0000 multiply by B + 0000 multiply by B 1 + 0000 multiply by B 2 + 1001 multiply by B 3 -------------- 1001000 Cross check 1 0 0 1 0 0 0 64 32 16 8 4 2 1 place value of result bits 64+8=72
Perform the following multiplication in binary number system : 1011 2 × 101 2 1 0 1 1 × 1 0 1 --------- 1 0 1 1 + 0 0 0 0 + 1 0 1 1 carry 1 ------------------- 1 1 0 1 1 1
Multiplication Binary, two n -bit values As with decimal values E.g., 1110 x 1011 1110 1110 0000 1110 10011010
Binary Multiplication Perform the following multiplication in binary number system: 15 10 × 8 10 Perform the following multiplication in binary number system: 1001 2 × 1101 2 Perform the following multiplication in binary number system: 111.11 2 × 101.1 2
Solve (205) 10 x (3) 10 (1110101) 2 x (1001) 2 (110) 2 x (10) 2 (1111101) 2 x (101) 2 (15) 10 x (8) 10