Home » 2s complement in C

What is the 2s complement in C?

The 2s complement in C is generated from the 1s complement in C. As we know that the 1s complement of a binary number is created by transforming bit 1 to 0 and 0 to 1; the 2s complement of a binary number is generated by adding one to the 1s complement of a binary number.

In short, we can say that the 2s complement in C is defined as the sum of the one’s complement in C and one.

2s complement in C

In the above figure, the binary number is equal to 00010100, and its one’s complement is calculated by transforming the bit 1 to 0 and 0 to 1 vice versa. Therefore, one’s complement becomes 11101011. After calculating one’s complement, we calculate the two’s complement by adding 1 to the one’s complement, and its result is 11101100.

Let’s create a program of 2s complement.

You may also like