Sign-Bit Processing of Signed Numbers

To my knowledge there are two ways to process the sign-bits of two signed numbers: the very well-known sign-extension method where the sign-bit is pushed forward based on the fact that -a=-2a+a, with a\in\{0,1\}, and, the correction term method, based on the formula -a=\bar{a}-1, with \bar{a} being the inverse of a.

Let’s illustrate by example: let X and Y be two signed numbers, n-bit and (n-1)-bit long, respectively. Their algebraic value in two’s complement representation is given by,

X=-x_{n-1}2^{n-1}+\sum_{i=0}^{n-2}x_i2^i and,

Y=-y_{n-2}2^{n-2}+\sum_{i=0}^{n-3}y_i2^i.

If we add both numbers, we obtain,

X+Y=-x_{n-1}2^{n-1}+(-y_{n-2}+x_{n-2})2^{n-2}+\sum_{i=0}^{n-3}(y_i+x_i)2^i,

and the term (-y_{n-2}+x_{n-2}) must be specially processed to get the final result in two’s complement representation. Now, applying sign-extension to the term yields, -y_{n-2}2^{n-1}+(y_{n-2}+x_{n-2})2^{n-2} and we are done. Alternatively, we can apply the correction term method, that is, (\bar{y}_{n-2}-1+x_{n-2})2^{n-2}. And, to get rid of the -1 we apply the fact that -1=-2+1, that is,

-2^{n-1}+(\bar{y}_{n-2}+1+x_{n-2})2^{n-2}.

What we obtain are just constant terms which can be easily processed.

In general, the sign-extension method incurs in higher fan-out of the operands, whereas the correction-term method suffers from additional inputs of the first-stage of processing. In any case, it is worth to ponder both options.

Leave a Comment