Two methods to begin with.
1. Sign/Magnitude representation
2. Ones complement method
Sign/Magnitude method : The leftmost bit is sign bit and remaining bits represent magnitude.
MSb is 0 for negative numbers and MSb is 1 for negative numbers.
Therefore we have +0 and -0. Not efficient.
One's complement method : the negative of a number is its ones complement(I expected something better).
therefore if 0 = 00000000, then 11111111 is -0. 1 = 00000001 and -1 = 11111110
Both these are not good enough, have drawbacks.Hence we have the Twos complement method.
That is negative of a number is its 2s complement(surprisingly simple).
Examples - +1 is 00000001. to get -1, take ones complement : 11111110, then add 1 : 11111111
therefore -1 = 11111111
Same method can be used to convert -ve number to +ve number to find out the magnitude.
for example, the value of 10100011 is found like this -
take ones complement - 01011100
add 1 : 01011101. this has magnitude 93.
therefore 10100011 = -93.
Here too, the MSb points to the sign of the number.
Reference - http://www.swarthmore.edu/NatSci/echeeve1/Ref/BinaryMath/NumSys.html
1. Sign/Magnitude representation
2. Ones complement method
Sign/Magnitude method : The leftmost bit is sign bit and remaining bits represent magnitude.
MSb is 0 for negative numbers and MSb is 1 for negative numbers.
Therefore we have +0 and -0. Not efficient.
One's complement method : the negative of a number is its ones complement(I expected something better).
therefore if 0 = 00000000, then 11111111 is -0. 1 = 00000001 and -1 = 11111110
Both these are not good enough, have drawbacks.Hence we have the Twos complement method.
That is negative of a number is its 2s complement(surprisingly simple).
Examples - +1 is 00000001. to get -1, take ones complement : 11111110, then add 1 : 11111111
therefore -1 = 11111111
Same method can be used to convert -ve number to +ve number to find out the magnitude.
for example, the value of 10100011 is found like this -
take ones complement - 01011100
add 1 : 01011101. this has magnitude 93.
therefore 10100011 = -93.
Here too, the MSb points to the sign of the number.
Reference - http://www.swarthmore.edu/NatSci/echeeve1/Ref/BinaryMath/NumSys.html
No comments:
Post a Comment