(unsigned) weights (powers of two)
4096 2048 1024 512 256 128 64 32 16 8 4 2 1
1111 1101 0111 0110(b) = ? decimal
Note: the left-most bit is "on", so this is a negative value.
We can't directly convert negative values.
We first make the value positive, and convert that.
To convert a negative bit pattern to positive, we can either subtract
it from 0, or reverse (flip) all the bits and add 1. Let's flip and add:
Negative: 1111 1101 0111 0110
flip bits: 0000 0010 1000 1001
add one: + 1
-------------------
Positive: 0000 0010 1000 1010
Now add up the powers of two that make up this positive binary value:
0000 0010 1000 1010 = 2^9 + 2^7 + 2^3 + 2^1
= 512 + 128 + 8 + 2 = 650 decimal
This positive value is as positive as the negative number was negative.
Therefore, the original negative number must be the minus of this value:
1111 1101 0111 0110(b) = -650(d)
----
0000 0001 0110 0000(b) = ? decimal
Note: the left-most bit is "off", so this is a positive value.
We do not need to do any bit flipping. Just convert it to decimal
by adding up powers of two:
0000 0001 0110 0000(b) = 2^8 + 2^6 + 2^5
= 256 + 64 + 32
= +352(d)
Hit the "Back" button.