Two’s complement is the way most computers represent integers. The highest bit indicates positive or negative:
0b0xxxxxxx = value is positive or zero
0b1xxxxxxx = value is negative
Convert positive value to negative
Invert the binary digits and add one to the result.
E.g. 1 / 0x01 becomes 0xFE, +1 = 0xFF
Convert negative value to positive
Invert the binary digits and add one to the result.
e.g. -1 / 0xFF becomes 0x00, +1 = 0x01
