Question: I'm working on Two's complement addition. Basically I need to show the addition of -27 to +31, with both numbers in binary using 6 bits. 

My problem is with carry operations. Maybe I'm not doing it right or something. 

-27 is in binary: 111011  

+31 is in binary: 011111

The answer I think should be:  

+4 is in binary: 000010

Here's what I'm doing: 

```
Carry  1 1 1 1 1  
- 27   1 1 1 0 1 1
+ 31   0 1 1 1 1 1
-------------------------
Sum:   0 1 1 0 1 0

```

Which in my mind computes to 52 not 4. 

What am I doing wrong?

Answer: 
your math is wrong.

27 is `0 1 1 0 1 1` in binary (note the leading 0 I added for the sign)

-27 is `1 0 0 0 1 1` in two's complement.

when you do the math with this, you should get the correct result.

---

Here's a "trick" to perform two's complement quickly.

Starting from the LSB, copy down the numbers exactly until you encounter the 1st zero, then copy that zero as well. After that, flip all the bits until the MSB. 

This is equivalent to flipping all the bits (one's complement) and adding one (to turn it into two's complement), but just in one step.
Hmmm, `31 - 27 = 4`, correct! :)

`4 is 100` in binary though, an are you sure that `-27 is 111011`???