Binary Addition, Multiplication, Subtraction,
And Division
Basic
mathematical operations with binary numbers works similar to the decimal
system. However there are a few rules specific to the binary system. We’ll look
at each of them individually.
Addition
There are 3
basic rules for adding binary numbers:
1.
0 + 0 = 0
2.
0 + 1 = 1
3.
1 + 1 = 10. If the sum of 2 bits is greater than 1, we need
to shift a column on the left. In decimal system, 1 + 1 = 2. Binary notation of
2 is 10 (1 * 2^1 + 0 * 2^0). So we keep 0 in the 1's column and shift (carry
over) 1 to the 2's column.
Other rules
are same as the decimal system, i.e. we add from right to left and the carry
over get’s added to the digits in the next column.
Now lets try
adding 11 to 13. Binary for 11 is 1011 and that for 13 is 1101.
1011
+ 1101
1.
1's col = 1 + 1 = 10. We keep 0 in 1's col and carry over 1
to 2's col.
2.
2's col = 1 + 0 + 1 (carry over) = (1 + 0) + 1 = 1 + 1 =
10. Once again we keep 0 in 2's col and carry over 1 to 4's col.
3.
4's col = 0 + 1 + 1 (carry over) = (0 + 1) + 1 = 1 + 1 =
10. Keep 0 in 4's col and carry over 1 in 8's col.
4.
8's col = 1 + 1 + 1 (carry over) = (1 + 1) + 1 = 10 + 1 =
11. Keep 1 in 8's col and carry over 1 in 16's col.
The sum is
11000. 11000 = 1 * 2^4 + 1 * 2^3 + 0 * 2^2 + 0 * 2^1 + 0 * 2^0 = 16 + 8 + 0 + 0
+ 0 = 24 = 11 + 13.
Multiplication
Multiplication
in binary is exactly as it is in decimal, i.e. multiply numbers right to left
and multiply each digit of one number to every digit of the other number, them
sum them up. The 3 basic binary multiplication rules are also similar to
decimal.
1.
1 * 1 = 1
2.
1 * 0 = 0 * 1 = 0
3.
0 * 0 = 0
Also,
remember that for every left shift of digit of the multiplier, an extra zero
needs to be appended to the product. This is similar to the decimal system as
well.
1011
X 1101
1.
1011 * 1 (multiplier 1's col) = 1011
2.
1011 * 0 (multiplier 2's col) = 00000 (one zero appended at
the end)
3.
1011 * 1 (multiplier 4's col) = 101100 (two zero’s appended
at the end)
4.
1011 * 1 (multiplier 8's col) = 1011000 (three zero’s
appended at the end)
5.
Sum up. 1011 + 00000 + 101100 + 1011000 = ((1011 + 00000) +
101100) + 1011000 = (01011 + 101100) + 1011000 = 110111 + 1011000 = 10001111
So the
product is 10001111 which is = 1 * 2^7 + 1 * 2^3 + 1 * 2^2 + 1 * 2^1 + 1 * 2^0
= 128 + 8 + 4 + 2 + 1 = 143 = 11 * 13.
Subtraction
Before trying
subtraction, we need to understand how negative numbers are represented in
binary. Whatever system is used (i.e. 4-bit, 8-bit, 16-bit etc.), signed number
must all have same number of bits. 0s are used to fill up empty bits. We’ll use
8-bit for this tutorial. There are 3 basic standards for notating negative
numbers.
- If you have to subtract small binary number from the large one then use the simple subtraction method as used in decimal number system.
- While if you have to subtract large binary number from the small one then use the special method ( Complementary Method ) of subtraction.
Division
Division method for the binary numbers is clearly explained in the video below:
Video quality theek nhe aa rhe ..
ReplyDeleteSorry! we will do our best to overcome this problem next time.
DeleteThanks for your review & suggestion.