Another approach finding the square of the binary
position |
4 |
3 |
2 |
1 |
bit |
1 |
0 |
0 |
1 |
Here, we have to find the position of 1 in the given binary number
In this example, the position of 1 are 1 and 4
append zeros equal to the $position (1) - 1$ to the right and add all the values to get the desired result
$1 - 1 = 0$ ( 0 zeros to be appended)
$4 - 1 = 3$ ( 3 zeros to be appended)
$1001_{2}+ 1001000_{2} = 1010001_{2} = 51_{16}$
Example 2:
suppose, you want to square $101100$.
the position of $1$ are $3, 4$ and $6$
$ ( 3 - 1 ) = 2 $ $\Rightarrow$$10110000_{2}$
$( 4 - 1 ) = 3$ $\Rightarrow$$101100000_{2}$
$(6-1 ) = 5$ $\Rightarrow$$10110000000_{2}$
$10110000_{2} + 101100000_{2} + 10110000000_{2} = 11110010000_{2}$