Given (52)10, (18)10 in decimal number system. We have to convert decimal numbers to binary numbers to perform 1's and 2's complement.
(52)10
(52)10=(110100)2
(18)10
(18)10=(010010)2
1's Compliment method:
(110100)2 - (010010)2
- First find the positive equivalent 1's compliment. To find 1's compliment, replace 1's with 0's and 0's with 1's.
1's compliment of (010010)2=(101101)2
- Add the above result to the (110100)2
$\begin{matrix} & _1 & _1 & _1\\ &1&1&0&1&0&0\\+&1&0&1&1&0&1\\\hline\\\underline1&1&0&0&0&0&1\\\downarrow\\\text{Carry}\end{matrix}$
- The Carry is generated in the above result.
Add the cary bit to the least significant bit [LSB] of the above result.
$\begin{matrix}&&&&_1\\1&0&0&0&0&\underline1&\rightarrow&\text{[LSB]}\\+&&&&&1\\\hline\\1&0&0&0&1&0&\rightarrow&\text{Answer}\end{matrix}$
(52)10 - (18)10 = (100010)2
2's Compliment method:
(110100)2 - (010010)2
- Find the negative equivalents 2's compliment. To find 2's compliment, find 1's compliment by replacing 1's with 0's and 0's with 1's, and add 1.
1's compliment of (010010)2=(101101)2
2's compliment of (010010)2=(101101+1)2=(101110)2
- Add (101110)2 to (110100)2
$\begin{matrix}&_1&_1&_1\\&1&1&0&1&0&0\\+&1&0&1&1&1&0\\\hline\\\underline1&1&0&0&0&1&0\\\downarrow\\\text{Carry}\end{matrix}$
- Discard the carry bit in 2's compliment
(52)10 - (18)10 = (100010)2