twoscomplement
Two's complement is a method for encoding signed integers in binary using a fixed number of bits. In an n-bit system, the representable integers range from -2^(n-1) to 2^(n-1)-1. Nonnegative values (0 to 2^(n-1)-1) are represented as their ordinary binary form, while negative values are represented by patterns in the upper half of the range. Arithmetic is performed modulo 2^n, so binary addition and subtraction wrap around within the n-bit space.
To obtain the two's complement (the negative) of a positive number x, you can either invert all
Two's complement has several advantages: it uses a single, uniform representation for all integers; there is