- The representation of a negative number
**B**in this format, is performed by computing**(K-B)**where**K = 2**such that^{n}**n**is the number of digits (bits) in**B**, that is**n = floor(log**. Rather than performing this computation, we can simulate it by the following algorithm:_{2}|B|) + 1To 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):
33

_{10}is 0010 0001_{2}

-33_{10}is 1101 1110_{2}

+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

© L.Heath, 2000