Computer Arithmetic
Digital Number Representation:-
In unsigned magnitude representation with 'n' bits, the possible integer values are [ 0 to 2n – 1)].
Extra bit is sign bit (MSB)
if MSB = 0 ----> positive number
if MSB = 1 -----> negative number
In a sign magnitude representation the range of number.
- ( 2n-1 – 1) to +(2n-1 – 1)
- ( 2n-1 – 1) to + (2n-1 – 1)
- ( 2n-1 – 1) to + ( 2n-1 – 1)
In unsigned magnitude representation with 'n' bits, the possible integer values are [ 0 to 2n – 1)].
Extra bit is sign bit (MSB)
if MSB = 0 ----> positive number
if MSB = 1 -----> negative number
In a sign magnitude representation the range of number.
- ( 2n-1 – 1) to +(2n-1 – 1)
In 1's complement representation, the positive number are represented similar to positive number sign magnitude, but for representing negative number, first consider positive number and then take 1's complement of that.
Range of 1's complement number,
- ( 2n-1 – 1) to + (2n-1 – 1)
In 2's complement representation of a number positive numbers are represented similar to positive number sign magnitude , but representing negative number first to write positive number then take 2's complement of it.
Range of 2's complement representation number:-
- ( 2n-1 – 1) to + ( 2n-1 – 1)
Binary Arithmetic:-
When both number have same sign then we add only magnitudes and use the sign as MSB.
1's Complement Addition
When the numbers have different sign, keep one number as it is and 1's complement the other then we add magnitude only.
If carry is present:
(I) Add carry to LSB
(II) Sign of the result is sign of the uncomplemented number.
If carry is not present:
(I) Take 1's complement as the result.
(II) Sign of the result is sign of the complemented number.
2's Complement Addition
In 2's complement method of representation if the number are of same sign then add the numbers and if carry is generated discard it and if carry is not generated take the 2's complement of results.
Over Flow
Overflow occurs when two same signed numbers are added in signed represented. To detect overflow we use XOR gate whose inputs are Cin and Cout where Cin is input carry to MSB and Cout is
output carry from MSB. Output of XOR gate is 1 then overflow , if it is zero then no overflow.
Cin -- 0 - No overflow
Cout --- 1 - Overflow
In 2’s complement representation there is only one
representation for zero while in 1’s complement representation there are two
zeros + 0 and – 0.
No comments