CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

1. Member
Join Date
Sep 2006
Posts
40

## One's Complement/Two's complement

ok, so I'm trying to understand one's complement and two's complement, but I feel like I'm missing something. I understand that to get the negative value in one's complement you flip the bits and in two's complement you flip the bits and add one. Is addition the same using both one's and two's complement?

Also, I have practice questions for one of my classes and I'm a little confused by how they are presented. The question simply says to do the arithmetic in either 2's complement or 1's complement and to indicate if overflow or underflow occurs, yet none of the questions indicate whether you are meant to by adding or subtraction. Here's one of the examples:
01101000
10001100

2. ## Re: One's Complement/Two's complement

Originally Posted by daydreamerz
ok, so I'm trying to understand one's complement and two's complement, but I feel like I'm missing something. I understand that to get the negative value in one's complement you flip the bits and in two's complement you flip the bits and add one. Is addition the same using both one's and two's complement?
No. Adding using the one's compliment doesn't really mean anything, right? What happens if you add 00101 to 11010? You get 11111! However, if you add the two's compliment of a number to another number, you are actually performing a subtraction (i.e. adding a number to a negative number, same as subtracting two numbers).
Originally Posted by daydreamerz
Also, I have practice questions for one of my classes and I'm a little confused by how they are presented. The question simply says to do the arithmetic in either 2's complement or 1's complement and to indicate if overflow or underflow occurs, yet none of the questions indicate whether you are meant to by adding or subtraction. Here's one of the examples:
01101000
10001100

Viggy

3. ## Re: One's Complement/Two's complement

Adding using the one's compliment doesn't really mean anything, right?
Actually it does. Fortunately 1's complement is rarely found in Software Systems. It is found (although much less than 20-30 years ago) in hardware systems.

The interesting "quirk" of 1's comp, is that there are two valid representations of "0" 0000000 and 1111111.

4. Junior Member
Join Date
Feb 2009
Posts
1

## Re: One's Complement/Two's complement

hi everybody
i have 2 quistions:
.first:why 1's complement and 2's complement are called by this names
.second:i understand the 2's complement that if we represent the integer in 8bits so we will have 8 positive number each of the will map to a number some of them
are positive(2^n-1)-1
and others are negative (2^n-1) and only one number will map to zero
so what is different in concept in 1's coplement , and 9's complement i cant understan its idea
and why in this (1's and 9's )there are tow representation of zero

5. ## Re: One's Complement/Two's complement

Base-1 Complement (1s complement for binary and 9s complement for decimal) are simple reflections.

Base Complement (2s complement for binary), is such that when you ADD the positive representation of a value you get all zeros.

Thus the former is easier to implement in hardware (anyone remember a 7404 ), but the latter is much more useful in computations.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•