NOTE ON THE TWO'S COMPLEMENT NUMBER CODE

Two's complement is the most common number code for storing integer values. Con sidering the following 8 bit "value box":

-128 64 32 16 8 4 2 1

Using this box and given the binary number 10001101, this will be equivalent to -128+8+4+1 = -115. Thus any two's complement number with a leading 1 represents a negative number (and vice-versa). Therefore, in the above case, the largest negative number that can be stored is -128, and the largest positive number is < tt>127.

To give two further examples the number 1 would be represented by the bit pattern 00000001, and the number -1 by the bit pattern 11111111.




Created and maintained by Frans Coenen. Last updated 11 October 1999