# Confusion with 1's and 2's complement

Hi

I am a college student.

I have a little confusion with these complements. Of course i know that in '+' and '-' 2's complement is used but is it limited to only '-' and '+'.

What are the places in which the 1's complement is used and what is the reason for not using the 2's complement there.

And finally why do we have 2 kinds of complements in the first place.

chroot
Staff Emeritus
Gold Member
1's complement is simply an inversion of all the bits.

2's complement acts as a "rotation" of the number circle, so that negative numbers can be represented, while addition and subtraction continue to work as expected. When you get into more complicated arithmetic (division, etc.) you'll generally be using more complicated floating-point formats.

- Warren

sylas
What are the places in which the 1's complement is used and what is the reason for not using the 2's complement there.

One place where ones complement is used in in checksums for error detection in data transmission. It turns out to be better than twos complement for error detection. For more detail, see Additive Checksums at neutrino.com

Cheers -- sylas

However 1s compliment is vanishingly rare in practice. All programming language implementations I am aware of internally use 2s compliment for normal negative integers.

sylas