8 bitTwo's complement in the simplest way possible please

39 views Asked by At

I really need help understanding twos complement. I have been set with the task of converting some negative numbers into binary using 8 bit Two's complete but I have literally no idea what I have to do. Can someone help, if someone could explain it in the simplest way that would be really helpful. Thanks again

2

There are 2 answers

0
Jotac0 On BEST ANSWER

The simplest way is : from right to left start copying all digits untill you get a 1, copy it too, then invert all the rest, so 1111 1011, you start copying the 1, you reached the first one, so next start inverting the rest: 0000 0101 witch is -5. another example: 1111 1000 -> 0000 1000 that is -8 I hope it helps. more info: Two's complement

0
Guffa On

The simplest way is to add 256 to the number.

For example, if you have -42, the two's complement is:

256 + -42 = 214

214 in binary is 11010110.

You can also do the calculation in binary, then you would subtract 42 from 256:

 100000000
-   101010
----------
  11010110