Given an 8-bit binary number/counter, why is it that 11111111 converts to -1 in decimal format?
Good question =) Well notice that there are different methods for that. It will be -1 in two's complement system. Basically you'd ask yourself, what number added to 1 will result in 0? Let's look in 4 bits, it will be easier. Remember we're limited only to 4 bits so any carry is dropped. $$ \begin{array}{lr} &0001\\ +&1111 \\ \hline &1 \boxed{0000} \end{array} $$ Likewise -2 will be the number that added to 2 will make zero so: $$ \begin{array}{lr} &0010\\ +&1110 \\ \hline &1 \boxed{0000} \end{array} $$so 1110 is -2, and so on. More generally you can say that to convert a number to its negative you have to first invert all the digits, because then we have: $$ \begin{array}{lr} &0101\\ +&1010 \\ \hline &1111 \end{array} $$And then by adding one to the inverted we'd get 0 instead of 1111 so: $$ \begin{array}{lr} &0101\\ +&1011 \\ \hline &1 \boxed{0000} \end{array} $$So the negative of 0101 (5 in decimal) is 1011 Notice that this is depended on the size of your register. so the negative of 000101 is 111011
Thank you!
You're welcome
Join our real-time social learning platform and learn together with your friends!