Two's Complement

The two's compliment value of a binary number is found by flipping all the bits and then adding 1.

For example, the two's compliment of `00010010` (18) is `11101110` (-18).

If the two's compliment of a number would add a ninth digit, the extra digit is ignored.

For example, the two's compliment of `00000000` (0) is `100000000`. Because `100000000` is 9 digits long, the leading `1` is ignored and the two's compliment becomes `00000000` (also 0).

To subtract two binary numbers, you can add the first number and the two's compliment of the second number. Remember to ignore the ninth digit!

For example `11101101 - 11100100` turns into `11101101 + 00011100` which equals `00001001`.