In: Computer Science
1. Add the following binary numbers in 4-bit, two's complement notation. Identify any overflow errors. 01102 + 01002
2.Add the following binary numbers in 4-bit, two's complement notation. Identify any overflow errors. 10102 + 11112
3.Add the following binary numbers in 4-bit, two's complement notation. Identify any overflow errors. 10112 + 01112
Solution:
since there are 4 bits therefore 2's complement can be within the range of (-24-1) to (+24 - 1-1) ie - 8 to +7
so by adding 2 numbers of 2's complement if they go outside that range then they are overflowing .
Hence :-
soln 1.>
Add 0110 + 0100
0110 in 2s complement = +6
0100 in 2s complement = +4
6+4 =+10 which goes outside they range since at max we can go to +7 using 4bits 2s complement notation therefore its an OVERFLOW
soln 2.>
Add 1010 + 1111
1010 in 2s complement = -6
1111 in 2s complement = -1
(-6)+(-1) =-7 which does not goes outside the range since at max we can go to -8 using 4bits 2s complement notation therefore its NO OVERFLOW
soln 3.>
Add 1011 + 0111
1011 in 2s complement = - 5
0111 in 2s complement = +7
-5 +7 =+2 which does not goes outside the range since at max we can go to +7 using 4bits 2s complement notation therefore its NO OVERFLOW
SHORTCUT(for
signed notation or 2s complement notation):-