-2

Say we are having 4 bits to represent a SIGNED number so, a total of 2^4 = 16 numbers (using 2's complement method). the range is from -8 to +7. The range, i see ,is from -7 to +7. if the first bit is all about the sign how come it represent a magnitude?. for eg:

to represent -7 we go first from +7 like first bit represent sign other magnitude

+7=0111(0 for +ve number)

the find its 2's complement (-7)

-7=(1000+1)=1001(1 for negative)

so don't we need 5 bits to represent -8 because 1st will represent the sign like

firstly, +8=01000(0 for +ve)

whose 2's complement is -8=(10111+1)=(11000) (1 for negative) how come -8 be only 1000.(isn't that 1 sign bit ) why is the sign also indicating the magnitude?Thank you!

prabesh013
  • 15
  • 2
  • 2's complement is not intended to be "sign bit" and "magnitude bits"; that would be sign-and-magnitude. The fact that the first bit is called a sign bit doesn't mean it's supposed to have no effect on magnitude. – user2357112 Apr 05 '18 at 19:27

1 Answers1

1

As stated in the comments, sign bit doesnt ensure that there is no effect on the magnitude. You said it yourself 2^4 = 16 number. This would be a range from 0 to 15 assuming every number is positive. When your using the first bit as a sign bit, it still has 16 different values but the range is changed to -8 to 7. Also realizing the twos compliments of 1000 is 1000, meaning you can never have a positive eight within the 16 digit range.

This should answer your question but if you are tring to achieve something, please be more specific about it.

  • so if i have 5 bits to represent a +8 which will be 01000(MSB 0 representing sign and other the magnitude) and 5 bits to represent -8 wouldn't that be same as 01000 as it only needs 4 bits(1000) and the MSB would be just 0 as 1000 represents -8 already..this got me into confusion.? – prabesh013 Apr 06 '18 at 04:06
  • So to dig a little deeper +8 would be equal to 01000. Now take the 2's compliment of that number and you get 10111+1=11000 keeping the sign bit true to its nature. This is why, when dealing with the sign bit, 4 bits can only represent up to +7 – Charles Plowman Apr 09 '18 at 14:09