Problems with Signed Magnitude Representation of Integers Illustrated

Two values for zero:

0000 0000 0000 0000   &   1000 0000 0000 0000

are both zero. The most significant bit is the sign: 0 for positive and 1 for negative.

(A - B) is not the same as (A + (-B), and it should be!

52 = 00110100 52 = 00110100
- 31 = - 00011111 - 31 = - 10011111
---- ---------- ---- ----------
21 = 00010101 21 != 11010011

Problems with One's Complement Representation of Integers Illustrated

Two values for zero:

0000 0000 0000 0000   &   1111 1111 1111 1111

are both zero. The most significant bit is the sign: 0 for positive and 1 for negative. Here as in Signed Magnitude, the computer processor must have extra circuitry to check for this after every operation.

In this case (A - B) is the same as (A + (-B):

52 = 00110100 52 = 00110100
- 31 = - 00011111 - 31 = - 11100000
---- ---------- ----------
21 = 00010101 111010011
+ 1
---- ----------
21 = 00010101

The processor must add 1 to the binary number if the operation results in an overflow.

The designer of the processor can use addition circuitry for subtraction by making the second operand negative.

Two's Complement - it works:

Form the One's Complement and add 1.

- 31 becomes 11100000
+ 1
----------
11100001
-(-31) becomes 00011110
+ 1
----------
00011111 As it should be

 

 

 

Last updated: September 11, 2003.