Convert 2's complement to decimal
If the number is positive then the binary representation is the number
eg 111 = 7, 101 = 5 etc ...
if the number is negative the most signigicant bit will be set to a one
if the word is a 16 bit integer then bit 15 will be set to 1 -
You need to flip all the bits that are one to 0 and all the bits that are 0 to 1's
eg: 1111 1111 1111 0110
flip 0000 0000 0000 1001 = 9
add 1
=10
and make it negative
-10
Or
1111 1111 1111 0110
Exclusive Or with
1111 1111 1111 1111
0000 0000 0000 1001
add 1
and make negative
Hope that helps!
|