next up previous
Next: Two's Complement Up: Integers Previous: Sign-Magnitude

One's Complement

In one's complement representation subtraction is performed by addition of a negative integer. This eliminates the need for a separate subtraction processor.

As in sign-magnitude, the leftmost bit indicates the sign of an integer in complement representation. The representation for positive integers is the same as unsigned with the leftmost bit = 0.

Negative integers are formed by reversing all bits to form the bitwise complement of a positive integer. If I is the (n+1) bit binary sequence:

displaymath2774

then -I in one's complement is given by:

displaymath2775

where tex2html_wrap_inline2784 for all i.

Let I be a negative one's complement integer. The value of I is obtained by forming its one's complement:

displaymath2776

since tex2html_wrap_inline2786 . Thus,

displaymath2777

Negative one's complement integers are formed by subtracting a bias of tex2html_wrap_inline2788 from the positive integers. Taking into account the sign bit tex2html_wrap_inline2790 , the value for a positive or negative (n+1) bit one's complement integer is:

displaymath2778

The range of values for an (n+1) bit one's complement integer is tex2html_wrap_inline2766 to tex2html_wrap_inline2788 .

Since the complement of 0 is tex2html_wrap_inline2762 , there are different representations for +0 and -0 in one's complement.

Examples of 8-bit one's complement numbers:

tabular540

The range of 8-bit one's complement integers is -127 to +127.

Addition of signed numbers in one's complement is performed using binary addition with end-around carry. If there is a carry out of the most significant bit of the sum, this bit must be added to the least significant bit of the sum.

To add decimal 17 to decimal -8 in 8-bit one's complement:

tabular555



CS 301 Class Account
Mon Sep 13 11:15:41 ADT 1999