Arithmetic Operations in binary number system
Till now, I have described the conversion of various
number system into binary number system.This article describes how to do
arithmetic operations in binary number system. We can add, subtract, multiply
or divide two numbers. However, microprocessors rarely use other arithmetic
operation rather than addition. Because making a logic gate for addition is
easier than making logic gates for subtraction or other arithmetic operations.
Computers subtract numbers by adding the 2’s complement form of numbers. So,
you must have to know how addition works.
Binary Addition
Two binary numbers can be added in the same way as two
decimal numbers are added. Before jumping to an example,let us see some basic
rule –
- 0 + 0 =0
- 0 + 1 = 1
- 1 + 0 = 1
- 1 + 1 = 10
The last rule may shock you but as you know binary number
system has only 0 and 1. So, the digit ‘2’ is not defined in binary number
system. After 1, binary number system recognize 10 because the number has ‘1’
and ‘0’.
See the example carefully,
Explanation:
Step 1:
The least significant bits are added, that is 1 + 0 = 1 with
a carry 0.
Step 2:
The carry in the previous step is added to the next higher
significant bits, i.e. 0 + 1 + 1 = 0 with a carry 1 (as 1 + 1 =10)
Step 3:
The carry in the above step is added to the next higher
significant bits, i.e. 1 + 0 + 0 = 1 with a carry 0.
Step 4:
The preceding carry is added to the most significant bits,
i.e. 0 + 1 + 1 =10
Thus the sum is 10101.The addition is also shown in the
decimal number system in order to compare the results.
Binary subtraction
Binary subtraction is also carried out in the same way as
decimal numbers are subtracted. jumping to an example, let us see some basic
rule –
- 0 – 0 = 0
- 1 – 0 = 1
- 1 – 1 = 0
- 10 – 1 = 1
Now, see an example –
Explanation
Step 1:
LSBs (least significant bit) in the first
column are 0 and 1. Hence, we have to borrow 1 from higher significant bits.So,the
subtraction is performed as 10 – 1 = 1
Step 2:
In the third column, the difference is given by 1 – 1 = 0
Step 3:
Finally subtraction between most significant digit is
performed i.e. 1 – 1 = 0
Binary Multiplication
Binary multiplication is not like decimal multiplication.
But it is very easy compared to its decimal counterpart. Let us see the steps –
Step 1:
The least significant bit of the multiplier is taken.If the
multiplier bit is 1,the multiplication is copied as such and, if the multiplier
bit is 0, a 0 is placed in all the bit positions.
Step 2:
The next higher significant bit of the multiplier is taken
and the partial product is written with a shift to the left, as in step 1.
Step 3:
Step 2 is repeated for all other higher significant bits and
each time a left shift is given.
Step 4:
When all the bits in the multiplier have been taken into
account, the partial product terms are added, which give the actual of the
multiplier and the multiplicand. The following examples illustrate the
multiplication procedure.
Now see an example
Hope, you get this. Is not it simple? Now I will not teach
you how we can divide numbers because there is no meaning to describe it. No
device uses division! It is also simple and similar to its decimal counterpart.
If you still want to know about division think yourself. I have given you the
hint already.
Comments
Post a Comment
If you have any doubt please comment and let me know