# Two's Complement

Two's Complement is a commonly used way to store bipolar data inside of a register. Traditionally, the data is arranged in the register so that the most significant bit is the sign bit (1 is negative, 0 is positive) and the remaining bits represent the data. While positive data can be read as is without any special manipulation, negative data tends to require some bit manipulation before the data can be accurately read.

To read negative data, users may approach the conversion in one of two ways (although these are not the only ways to approach it). One way is to drop the sign bit (the MSB), invert all of the bits (~ operator), and then add a 1 to the result. This will produce the desired result (albeit without the negative sign). An example with an 8-bit number is provided below:

Alternatively, users can add the unsigned value of the two's complement number (essentially read the number as if it was not a two's complement number) to -2^{N} where N is the number of bits that the number is represented with. An example with an 8-bit number is provided below:

Additional information about Two's Complement can be found on its Wikipedia Article.