Compute the sum and product of 101112 and 111002 while stayi
Compute the sum and product of (10111)_2 and (11100)_2, while staying in the binary system. For the sum, count the number of bit additions that are required.
Solution
The rules for binary addition includes
0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 10 (which is 0 carry 1)
Let us take these and add given numbers
1 0 1 1 1
1 1 1 0 0
+
1 0 0 1 1 (now here starting from right most bit 1+0 is 1, then next is 1+0 which is 1, then 1+1 which is 10(written as 0 and carry 1, now this carry goes to next bit and makes it 1+1 again 0 and carrry 1 then goes to next 1+1 with carry 1 , which makes it 1)
Multiplication of binary number and rules it uses are
0 x 0 = 0
1 x 0 = 0
1 x 1 = 1
Let us see multiplication of 10111 and 11100
Answer is 001100100
| 1 | 0 | 1 | 1 | 1 | ||||
| 1 | 1 | 1 | 0 | 0 | ||||
| 0 | 0 | 0 | 0 | 0 | ||||
| 0 | 0 | 0 | 0 | 0 | X | |||
| 1 | 0 | 1 | 1 | 1 | X | X | ||
| 1 | 0 | 1 | 1 | 1 | X | X | X | |
| 1 | 0 | 1 | 1 | 1 | X | X | X | X |
| 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 |
