Check out illinois-ipass.com, another site I earn revenue from ads on

An introduction to two’s complement along with its definition and calculations

The two’s complement is the most commonly used technique of mathematics that is
widely used in number theory and other relevant branches. It is an operation that
decodes the positive and negative numbers in the form of machine language like 0 & 1.
There is another operation such as one’s complement but it is only applicable for
converting positive numbers. So to reduce the difficulty of encoding the negative
integers, the two’s complement is used. In this post, we will learn the definition and
conversions of 2’s complement along with its calculations.

Introduction to Two’s Complement

Two’s complement is a way to represent negative numbers in binary form. It is the
standard way to represent negative numbers in computer memory, and it is used by
most digital devices. To calculate two's complement, start with the positive number and
add 1 to the rightmost bit. The resulting number is the two's complement of the original
number.

What Is Two’s Complement?

Two’s complement is a number system that uses the most negative integer as its base.
This number system is used in computing and electronics. It is also used in
telecommunications and navigation systems.

Two’s complements are used in computing and electronics because they provide a way
to represent negative integers. For example, with two's complement notation, it is
possible to represent -128 through 127 in an 8-bit system.

Conversions of binary and decimals to two’s complement

Let us discuss the conversions of binary, positive decimal numbers, and negative
numbers to two’s complement.

Binary to 2s complement

Follow the below steps to convert a binary number into the form of two’s complement.
1) First of all, take a binary number in 8, 12, or 16-bit form. Add zeros to the left
side, if the bit system is not complete i.e. if the binary number is 101101 then it
would be 00101101 in 8-bit system.
2) Take the transpose of the 8, 12, or 16-bit binary numbers i.e., invert all the zeros
to one and ones to zeros. This will give you the result of one’s complement.
3) After inverting, add one to the number at its least significant bit place.
4) The final result will give you the two’s complement.

Decimal to 2s complement

Follow the below steps to convert a decimal number into the form of two’s complement.
For positive decimal number
1. First of all, take a positive integer and convert the number into binary form.
2. Complete the bit system by adding additional zeros to the leftmost places.
3. Take the transpose of the 8, 12, or 16-bit binary numbers i.e., invert all the zeros
to one and ones to zeros. This will give you the result of one’s complement.
4. After inverting, add one to the number at its least significant bit place.
5. The final result will give you the two’s complement.

For negative decimal number
1) First of all, take the negative decimal number and deal it with respect to the
positive decimal number and calculate the two’s complement of it.
2) After that treat the two’s complement of positive number as a binary number and
complete the bit system.
3) Take the transpose of the 8, 12, or 16-bit binary numbers i.e., invert all the zeros
to one and ones to zeros. This will give you the result of one’s complement.
4) After inverting, add one to the number at its least significant bit place.
5) The final result will give you the two’s complement.

How to Calculate Two’s Complement?

Two’s complement is a type of number that is used to represent negative numbers. It
can be calculated either by using a two’s complement calculator or manually.
Let us take a few examples to learn how to calculate it manually.

 

Examples of binary to 2s complement

Example 1: for a 12-bit number system
Calculate the two’s complement of the given binary number 1100101011.
Solution
Step 1: First of all, complete the bit-system by adding zeros to the leftmost place.
Since there are 10 digits in the binary number so we will add 2 zeros to complete the
12-bit number system.
001100101011
Step 2: Now take the transpose of the 12-bit number by converting all the zeros to ones
and vice versa.
Binary number = 001100101011
Transpose of 001100101011 = 110011010100
Step 3: Now add one to the above-inverted number at the least significant bit place.

twos complement

Hence, the 2s complement of the given binary number is 110011010101.
Example 2
Calculate the two’s complement of the given binary number 1110101110101.
Solution
Step 1: First of all, complete the bit-system by adding zeros to the leftmost place.
Since there are 13 digits in the binary number so we will add 3 zeros to complete the
16-bit number system.
0001110101110101
Step 2: Now take the transpose of the 16-bit number by converting all the zeros to ones
and vice versa.
Binary number = 0001110101110101
Transpose of 0001110101110101 = 1110001010001010
Step 3: Now add one to the above-inverted number at the least significant bit place.
1 1 1 0 0 0 1 0 1 0 0 0 1 0 1 0

binary

Hence, the 2s complement of the given binary number is 1110001010001011.

Examples of decimals to 2s complement

Example I: For a positive decimal number
Calculate the two’s complement of the given decimal number 156.
Solution
Step 1: First of all, convert the given positive decimal number into a binary number.
positive decimal number = 156

The binary number of 156 = 10011100
Step 2: Now complete the bit-system by adding zeros to the leftmost place.
Since there are 156 is a 12-bit number and there are 8 digits in the binary number so we
will add 4 zeros to complete the 12-bit number system.
000010011100
Step 3: Now take the transpose of the 12-bit number by converting all the zeros to ones
and vice versa.
Binary number = 000010011100
Transpose of 000010011100 = 111101100011
Step 4: Now add one to the above-inverted number at the least significant bit place.

Example II: For a negative decimal number
Calculate the two’s complement of the given decimal number -116.

Solution
Step 1: First of all, convert the given decimal number into a binary number according to
the positive term.
Negative binary number = -116

The binary number of 116 = 1110100
Step 2: Now complete the bit-system by adding zeros to the leftmost place.
Since there are 116 is an 8-bit number and there are 7 digits in the binary number so we
will add 1 zero to the complete 8-bit number system.
01110100
Step 3: Now take the transpose of the 12-bit number by converting all the zeros to ones
and vice versa and add 1 to the least significant bit of the inverted binary number.
Binary number = 01110100
Transpose of 01110100 = 10001011

The two’s complement of 116 is 10001100
Step 4: Now treats the two’s complement of positive number as a binary number and
takes a transpose of it.
The transpose of 10001100 = 01110011
Step 5: Now add one to the above-inverted number at the least significant bit place.

Bottom Line

In conclusion, the two’s complement is a powerful number system that has many
advantages. It is easy to calculate, and it can represent both positive and negative
numbers. Additionally, the two’s complement is used in many applications, including
computer science and engineering.

 

You can also check out my post on SAT math tips.

About me
sarah lim

Check out illinois-ipass.com, another site I earn revenue from ads on

I'm Sarah Lim
My Skills

Web Developer

Social Media + SEO