Addition of
two positive number:
The addition of positive number follows the same rules that of the
binary addition.
The
magnitude of the sum should be in range(ie it should not go out of
range of the system). If the sum goes out of range the sign bit will
become 1.
Eg
+8 0,1000
+10
0,1010
---------
1,0010
(This answer is incorrect because in here we consider a 4bit
operands)
2's
complement subtraction: It
is the addition of minuend to the 2's complement of the subtrahend.
The sign bits of the two numbers are considered as a part of the
number and is used in the addition.
Eg
+5 0,0101
-3
1,1101 (2's complement of 3)
---------
+2
10,0010 (the one is ignored)
The
over flow produced in the addition is ignored. The bit in the sign
bits position will be the correct sign bit after addition. If the
result is negative it will be in 2's complement form.
Eg
-5 1,1011
+3
0,0011
--------
-2
1,1110
Addition of
two negative numbers in 2's complement form: Here
also the over flow bit is discarded. The sign bit is correct if the
result is in the allowed range(for 4 bit operand the range is <=15).
The sign bit will become 1 indicating error if the answer goes out of
range.
Eg
-5 1,1011
-3
1,1101
---------
-8
11,1000
Eg
-8 1,1000
-9
1,0111
----------
10,1111
(not correct as the result goes out of range)
No comments:
Post a Comment