decimalunsigned-integersigned-integer

Binary to 16 Bit unsigned & 16 bit signed magnitude


I missed a day of class due to illness, so I checked out my profs. material for that day online and I'm stuck on this. His notes don't have an explanation on how to do it. I can do conversions between the masses (decimal to octal, hex, binary etc.), but I can't do this.

Any help? An example would really help me understand quickly. I'll post his slideshow example:

1010 0000 0100 0101 as an unsigned value
= (1 * 2^15) + (1 * 2^13) + (1 * 2^6) + (1 * 2^2) + (1 * 2^0)
= (32,768) + (8192) + (64) + (4) + (1)
= 32,768 + 8261 = 41,029 base 10



1010 0000 0100 0101 as a signed value
= - [(1 * 2^13) + (1 * 2^6) + (1 * 2^2) + (1 * 2^0)] 
= -8,261 base 10

I guess I should really attend class even when I'm sick.


Solution

  • Sign is the 15th bit. So all you have to do is basically count places with ones (i.e. 2^place) and add them together.