Archive for November, 2008

Two’s Complement versus One’s Complement

Let \{z_{n-1},\dots,z_0\} represent a n-bit number in two’s complement. Its algebraic value, Z^{2s}, is given by,

Z^{2s}=-z_{n-1}2^{n-1}+\sum_{i=0}^{n-2}{z_i 2^i},

which equals to

-z_{n-1}2^{n}+[ \sum_{i=0}^{n-1}{z_i 2^i} ],

and, thus, the so-called 2^n-complement. Now,  the same n-bit number interpreted as a one’s complement number, (2^n-1)-complement, results in

Z^{1s}=-z_{n-1}(2^{n}-1)+[\sum_{i=0}^{n-1}{z_i 2^i}] .

Therefore,

Z^{1s}=Z^{2s}+z_{n-1}.

Note how the conversion is possible. Extending the previous equation we obtain

Z^{1s} = -z_{n-1}(2^{n-1}-1)+ \sum_{i=0}^{n-2}{z_i 2^i},

or,

Z^{1s}=-z_{n-1}2^{n-1}+\sum_{i=1}^{n-2}{z_i 2^i} + (z_{n-1}+z_0)2^0.

Interpreting two’s and one’s complement numbers in the framework of digit-set conversions, it is apparent that the MSB of a two’s compl. and a one’s compl. number,-z_{n-1}, takes values in [-1,0]. Unlike two’s compl., the LSB of a one’s compl. number,(z_{n-1}+z_0), takes values in [0,1,2].

Leave a Comment