Using signed integer representations, signed magnitude, one's complement and two's complement. Signed magnitude its main purpose to use the remaining bits to clarify magnitude of numbers and always the positive numbers take the the same representation in one's or two's complement. In negative number the case is different and easy add or subtract two negative numbers and so. For example let's represent number 10 in binary. 10 in binary = 1010 we have four bits and you can imagine which limit you want like 8 bits that will contain the 10 representation, it will be 00001010 , all zeros on the left mean this number is a positive number.
What about -10 ?
In easy way, keep in mind negative number carries (1s) instead of zeros as the same with the above example for 00001010. which these zeros in the bit string 1111 you can call this high-order bit , the remained 1010 should be changed each bit to the negative. Watch this.
10 = 1010 in binary-10 = 0101 in binary
So -10 in the string length will look like this binary representation which is exactly one's complement 11110101.
In two's complement representation we just add one to the number of one's complement, as we mentioned about this binary string 11110101 which represents -10.
1 1 1 1 0 1 0 1
1 +
____________
Just added one, then find the sum:
1 + 1 = 10 ( Note keep in mined in binary 1 + 1 = 10 ) put zero and carry one on the top of zeros in the second bit from the right.
1
1 1 1 1 0 1 0 1
1 +
____________
1 1 1 1 0 1 1 0
1+1= 10, put zero then carry on on the second bit it has zero no more tens just one, add it then the normal string . This the two's complement representation 11110110.
0 comments:
Post a Comment