Day 42: Computer Arithmetic

Hello Dear Students,
Hope you all are doing good.

Aaj hum computer arithmetic ke baare mein study karenge, means computer mein kaise arithmetic perform hote hain, addition, subtraction, multiplication, division.

Let's get started...

As we all know, computer can only understand the binary language, means 0s and 1s. So, computer mein jab bhi operations perform kiye jate hain, wo binary form mein kiye jate hain. 
Basically, the computer arithmetic deals with the method of representing fixed and floating-point numbers in digital systems.

Computer arithmetic performs on binary numbers-
  1. Binary Addition
  2. Binary Subtraction
  3. Binary Multiplication
  4. Binary Division

1. BINARY ADDITION - Binary addition mein hum 0s and 1s hi lete hain, isme hum binary numbers mein addition operation perform karte hain. Binary addition perform karne ke liye 2 situations hoti hain, which are-
  1. Half Adder - Half Adder mein 2 input values hoti hain and 2 output values hoti hain.
  2. Full Adder - Full Adder mein 3 input values hoti hain and 2 output values hoti hain.
Half Adder: X and Y are inputs, and Sum and Carry are outputs.
XYSumCarry 
 0 0 0
 0 1 
100
0

Full Adder: X, Y and PC are inputs, and Sum and Carry are outputs.
XYPC(Previous Carry) SumCarry to next Position 
 0 0 0
 0 0 
01           0             
00
0
1


2. BINARY SUBTRACTION - The subtraction is also same, to subtract the binary values. It has 2 methods-
  1. Simple methods- Half and Full Subtraction
  2. Component method- 1s and 2s complement.
1. Simple Methods of Binary Subtraction
Half Subtraction 
XYDifference Borrow 
 0 0 0
 0 1 
100
0

Full Subtraction
XYPB(Previous Borrow) DifferenceBorrow from next Position 
 0 0 0
 0 0 
01           1             
00
0
0
1


2. Complement Method 

1s Complement - 1s complement is very simple. 0 ki jagah 1 and 1 ki jagah 0. For example, the 1s complement of 110 is 001.

2s Complement - 2s complement mein simply hum sabse pehle 1s complement find out karenge and then uss 1s complement mein 1 ki addition kar denge. For example, the number is 110, so the 2s complement of 110 is firstly find 1s complement and then add 1.
1s complement of 110 is 001, now add 1 to 001.
001
+ 1
------
010
-----

So, the 2s complement of 110 is 010.

Binary Subtraction using 1s complement, Suppose m and n are 2 binary numbers to be subtracted, steps-
  1. Jo 2 binary numbers ki hum subtraction karne chahte hain, sabse pehle hum check karenge ki wo 2 numbers ke digits are same or not. Agar digits same nahi honge, then, jisme digits less honge uske beginning mein 0 ko laga denge.
  2. Then, n ka 1s complement find out karenge.
  3. Add n's 1s complement and m.
  4. Agar carry hota hai then, wo carry ko result ke saath add kar diya jata hai.
  5. Agar carry nahi hota then, re-complement karne ke baad result ke saath negative sign laga diya jata hai.
Example 1: Subtract 101 from 1110.
Here, m = 1110 and n=101.

So, lets find out its solution step by step:-
  • m=1110 and n=0101
  • 1s complement of n=1010
  • Add m and n's 1s complement= 1110+1010
 =  1110
   +1010
   ----------
 (1)1000 
   ----------
  • Here is carry of 1, then 
 1000
+     1
 --------
 1001
 --------

So, subtracting 101 from 1110, with 1s complement, we get 1001.

Note :- Suppose if there was not carry, then, the result was 1000, but since no carry is there so the result would be it's complement, i.e. -0111.(with negative sign).


Binary Subtraction using 2s complement - Suppose m and n are 2 binary numbers to be subtracted, steps-
  1. Jo 2 binary numbers ki hum subtraction karne chahte hain, sabse pehle hum check karenge ki wo 2 numbers ke digits are same or not. Agar digits same nahi honge, then, jisme digits less honge uske beginning mein 0 ko laga denge.
  2. Then, n ka 2s complement find out karenge.
  3. Add this 2s complement with m.
  4. Agar carry hota hai then, wo carry ko ignore kar diya jata hai and result is positive binary number.
  5. Agar carry nahi hota hai then, re-complement karne ke baad result ke saath negative sign laga diya jata hai.
Example 1: Subtract 1001 from 1110 by 2s complement
  • Here, m=1110 and n=1001.
  • 1s complement of n= 0110. 2s complement = 0110+1 = 0111.
  • Add m and 2s complement of n.
   1110
+ 0111
  -------
(1)0101
 --------
  • Here carry of 1, so ignore carry and thus the result is 0101.
Note:- If there is no carry suppose, 0101, then re-complement this as, 1010, so result is -1010.


3. SUBTRACT MULTIPLICATION - Binary Multiplication is very simple. Jaise hum simple multiplication operation perform karte hain, binary numbers mein bhi multiplication same hoti hai.

For example, two binary numbers 1011 and 1010 are multiplied as follows-
           1011
        x 1010
-------------------
            0000
+         1011x
+       0000xx
+     1011xxx
--------------------
   =  1101110
---------------------


4. BINARY DIVISION -   Binary division is also same as normal division. 

For example, 101101 divided by 101.

 




Best of Luck Students,
Do visit our website regularly for more content and for daily tests.

Regards,
UGC NET EXPERTS