sum carry
0 + 0 = 0 0
1 + 0 = 1 0
0 + 1 = 1 0
1 + 1 = 0 1
example ↓
1 1 0
+ 1 0 1
--------
1 0 1 1
1 1 0 1 1
+ 1 1 1 1
----------
1 0 1 0 1 0
1 1 1 0
- 1 1 1
-------
0 1 1 1
1 1 0 1 1
- 1 0 1 1 0
---------
0 0 1 0 1
product
↓
0 x 0 = 0
1 x 0 = 0
0 x 1 = 0
1 x 1 = 1
example ↓
1 0 1 0
x 1 0 1
-------
1 0 1 0
0 0 0 0 x
+ 1 0 1 0 x x
-----------
1 1 0 0 1 0
1 1 0 1
x 1 1
--------
1 1 0 1
+ 1 1 0 1 x
-----------
1 0 0 1 1 1
0 1 1 0 0 1
↓ ↓ ↓ ↓ ↓ ↓
1 0 0 1 1 0
0 1 1 0 0 1 ← number
1 0 0 1 1 0 ← 1's complement
+ 1 ← add 1 to 1's complement
------------
1 0 0 1 1 1 ← 2's complement
1 0 1 1 1 0 0 0
↓
0 1 0 0 1 0 0 0
Example 1. Perform following subtraction using 1's complement.
(i) 7 - 3
(ii) 3 -
7
Solution. (i) 7 - 3
Solution. (ii) 3 - 7
2's complement subtraction
Example 2. Perform following subtraction using 2's complement.
(i) 7 - 5
(ii) 5 -
7
Solution. (i) 7 - 5
Solution. (ii) 5 - 7
Steps ↓
Steps ↓
9 ---> 1 0 0 1
+8 ---> 1 0 0 0
---------------
17 ---> 1 0 0 0 1
Thus, addition of two 4-bits numbers requires 5-bits (n+1 bits) to represent the sum. What does a
computer then do in this scenario? A computer will discard the most-significant bit (MSB) and
keep the rest.
Binary to Gray code conversion lecture
XOR table
Example 1
1 0 1 1 = 1 ( 1 ^ 0 ) ( 0 ^ 1 ) ( 1 ^ 1 )
= 1 1 1 0
(1011)2 = (1110)gray
Example 2
11001 = 1 ( 1 ^ 1 ) ( 1 ^ 0 ) ( 0 ^ 0 ) ( 0 ^ 1)
= 10101
Decimal BCD X-3
0 0000 0011
1 0001 0100
2 0010 0101
3 0011 0110
4 0100 0111
5 0101 1000
6 0110 1001
7 0111 1010
3 → 0011
6 → 0110
4 → 0100
364 → 0011 0110 0100
Decimal 6 4 3
Add 3 to each 3 3 3
Sum → 976
Converting the sum into BCD code we have 9 7 6
↓ ↓ ↓
1001 0111 0110
1 0 0 0 → 8
+ 0 1 0 1 → + 5
----------- -----
1 1 0 1 13
since, (1101)2 > (9)10 add 6 (0110) to it
1 1 0 1
0 1 1 0
-------
1 0 0 1 1
↓ ↓
1 3
So, result = 00010011
Solution. (ii)
1 ← ← ← Carry generated
0 0 0 1 1 0 0 1 → 19
0 0 0 1 1 0 0 0 → +18
----------------- ----
0 0 1 1 0 0 0 1 37
Since, a carry is generated we must add 6 (0110) to it.
So, 0 0 1 1 0 0 0 1
0 1 1 0
-------------------
0 0 1 1 0 1 1 1 → (37)10
So, result = 00110111
We know that data is transmitted in binary form.
While transmission of data, if noise are added to the data then it will not be same in receiving
side as it will contain some error.
There are two types of parity bit code
How many parity bit can 'm' number of bit message can have?
Now we will see where to place the parity bits within the message.
Let the code is of 7 bits.
There is a rule: the parity bits can always be place at position 2n where n = 0,
1, 2, 3, ...
What will be the value of parity bits?
Example question:
Encode the binary word 1011 into seven bit even parity hamming code.
Determine the hamming code for 10111 for odd parity.
Assume that the even parity hamming code 0110011 is transmitted & that 0100011 is recevied. The receiver does not know what was transmitted, determine the error location.
References