Complements 1
Complements 1
operation and logical manipulation. There are two types of compliments for
each base r system. The r’s complement and (r-1)’s complement.
1’s complement:- In Binary number radix or base =2, & r-1 i.e. (2-1)=1, so
1’s complement of a number N is : (rn-1)-N
Ex:- if n=3
Then 23=[1000]2
& 2n-1 = 1000-1=111
If n=4
Then 24=[10000]2
& 2n-1 = 1000-1=1111
So the 1’s complement of a binary number is obtained by subtracting each
digit from 1. The subtraction of a binary digit from 1 causes the bit to
change from 0 to 1 or from 1 to 0.
→(1000000-1)-1
→999999-742100
→257899
10’s Complement:- The 10’s complement of an n digit number N in base 10 is
defined as 10n-N for N≠0 and 0 for N=0. We can also obtain 10’s complement
by adding 1 to the 9’s complement.
10’s complement can also be formed by leaving all the least significant
0’s unchanged, subtracting the first non-zero least significant digit from
10, and then subtracting all higher significant digits from 9.
Ex:- 10’s complement of 74150
Formula (10n –N)
First method second method Third method
here n=5 and N=74150 7 4 1 5 0 9 9 9 9 9
10 -74150
5
2 5 8 5 0 - 7 4 1 5 0
100000-74150 ---------------
25850 2 5 8 4 9
+ 1
---------------
2 5 8 5 0
Binary Arithmetic:
Binary Addition:-
Let X represent single bit number either 0 or 1. Any Y represents another
single bit either 0 or 1. Therefore single bit binary addition is:
Note:- In case where X=1 and Y=2 binary addition is consistent like decimal
number addition. The binary sum of two number should be equivalent to the
decimal sum obtained by adding the same two numbers in decimal for example:
(1)10 + (1)10 = (2)10
(1)2 + (1)2 = (2)10 or (10)2
Binary Subtraction:- Subtraction of 0 from a number does not change its
value, while subtracting 1 reduces its value by 1. Now in order to subtract
1 from 0 we must borrow a 1 from the next most significant bit. It is also
done like decimal arighmetic.
Let X represent a single bit number either 0 or 1 and Y be another single
bit number either 0 or 1 therefore
X Y X-Y
0 0 0
1 0 1
1 1 0
Binary Multiplication:- Procedure for multiplying binary numbers containing
any number of bits is exactly the same as that used for multiplying decimal
numbers. It begins with least significant bit of multiplier, we multiply
each bit of multiplicand one bit at a time and the results are written in a
line. The line of result is called partial product. This process repeated
for each bits in the multiplier at the same time shifting the next partial
product one position to the left. After the process has been completed for
each bit in the multiplier the result is added.
For Example:-
1 1 0 Multiplicand
1 0 1 Multiplier
1 0 0
0 0 0 Parital Product
1 1 0
1 1 1 0 0 Product
Binary Division:-
Binary division is as same as that of decimal division.
For Example:
110 11110 101
110
xx110
110
000
Arithmetic operation (Addition/Subtraction) on numbers:
We can perform these operations using following methods:-
1. Signed magnitude representation.
2. Signed 1’s complement
3. Signed 2’s complement
1. Signed magnitude representation:- Add 25 and -30 in binary using 7 bit
register. To do the arithmetic addition using one negative number we have
to check the magnitude of the number. The number having smaller magnitude
is then subtracted from the bigger number and then the sign of bigger number
is selected.
e.g.:- + 2 5 → 0 0 1 1 0 0 1
- 30 → 1 0 1 1 1 1 0
Sign Bit
Now Subtract 1 0 1 1 1 1 0
- 0 0 1 1 0 0 1
1 0 0 0 1 0 1 ➔ -5
2. Arithmetic subtraction suing 1’s complement:-
The subtraction can be easily done using 1’s complement of the subtractend
(including sign bit) and then adding both numbers including sign bit. If
carry of the most significant bit or sign bit is 1, then increment the result
by 1 and discard the carry over. If the result is in negative i.e. it is
in 1’s complement.
For example
1. Add -25 and +30
Here subtractend is 25 and its binary representation
25 = 0 0 1 1 0 0 1
and its 1’s complement is 1 1 0 0 1 1 0
+30= 0 0 1 1 1 1 0
Now add:
1 1 0 0 1 1 0
0 0 1 1 1 1 0
1 0 0 0 0 1 0 0
Here, the carry is 1 out of sign bit so, the result get increment by 1 and
this 1 is out of sign bit so this is discarded.
0 0 0 0 1 0 0
+ 1
0 0 0 0 1 0 1 ➔ +5 Ans
2. Add -25 and -30
+25= 0 0 1 1 0 0 1 → 1’s complements= 1 1 0 0 1 1 0
+30= 0 0 1 1 1 1 0 → 1’s complements= 1 1 0 0 0 0 1
Now add both the complements 1 1 0 0 0 1 1 1
Here 1 is overflow so 1 is added + 1
to the result 1 0 0 1 0 0 0
Here sign bit has 1. It means result is in 1’s
complement form and the result will be negative
so to find the answer we have
to complement the result. 0 1 1 0 1 1 1 → -55
3. Arithmentic operation using 2’s complement:-
4. The subtraction can easily done using the 2’s complement by taking
the 2’s complement of the subtractend (including sign bit) and then
adding both the numbers including sign bit and discard any carry out
of the sign bit position. If the result is negative it is in 2’s
complement.
For example :-
Add 25 and -30
+25 = 0 0 1 1 0 0 1
+30 = 0 0 1 1 1 1 0
2’s complement of +30 is 1 1 0 0 0 1 0
Now add +25 and 2’s complement of +30
1 1 0 0 0 1 0
0 0 1 1 0 0 1
1 1 1 1 0 1 1
Since sign bit has value 1. It means result is in 2’s complement. So we
have to convert it into general form. For this we will subtract 1 from the
result and then complement the result as given below:
1 1 1 1 0 1 1
-1
1 1 1 1 0 1 0
Now 1’s complement of result 0 0 0 0 1 0 1 → 5 Ans.