REPRESENTING NEGATIVE NUMBERS
The most commonly used representation is called two's complement. [**]

• The representation of a negative number B in this format, is performed by computing (K-B) where K = 2n such that n is the number of digits (bits) in B, that is n = floor(log2|B|) + 1. Rather than performing this computation, we can simulate it by the following algorithm:

To find the representation of a negative integer B, complement the bits of the representation of B, and add 1,
where complement: if (bit = 0) then bit <- 1 else bit <- 0

• Examples (assuming 8 bits):

3310 is 0010 00012
-3310 is 1101 11102
+1
--------------------------
1101 1111
--------------------------

-1 is 1111 1111
-2 is 1111 1110
-3 is 1111 1101
::
::
-128 is 1000 0000
127 is 0111 1111
::
::
2 is 0000 0010
1 is 0000 0001
0 is 0000 0000

## More Tutorial Help:

See the Case Western Reserve University explanation. .

## One's Complement:

One's complement is simply the complement of the number representation (without the addition of 1).

CS1104 Main Page
Last Updated 09/21/2000