2s Complement Arithmetic

💡
Key learnings:
  • 2s Complement Definition: 2s complement arithmetic is a method for representing signed binary numbers and performing arithmetic operations on them.
  • Binary Representation: To represent a negative number in binary, find the number that adds to the original to make zero, then flip all bits and add 1.
  • Sign Bit: The leftmost bit of a binary number shows its sign—0 for positive and 1 for negative.
  • 2s Complement Addition: Add numbers directly, ignoring any carry beyond the leftmost bit for simplicity.
  • 2s Complement Subtraction: Convert the subtrahend to its negative form using 2s complement, then add it to the minuend.

2’s complement has the unique property of simplifying binary arithmetic operations for both signed and unsigned numbers, always yielding the correct result.

How to represent decimal number in 2’s complement?

Let us take a number. A negative number is defined as a number that, when added to its positive counterpart, results in zero. Let’s use the decimal system as an example.
Where,
In the binary system, there are only two digits: 0 and 1. Every number and its sign are represented using these digits. Since we can’t write positive and negative signs directly in binary, we use an alternative method to represent them.

For that we take advantage of definition of negative number. To represent a negative binary number, we find a binary number that sums to zero with the original positive binary number. This second number is the negative equivalent of the first number.
Suppose we have to write – 5 in binary which is negative of 5 or + 5. Now 5 or + 5 can be represented in binary byte or 8 bits system as 0000 0101 and zero is represented in binary byte or 8 bits system as 0000 0000.

Hence this result is representation of (- 5)10.

Now let us examine 2’s complement of 0000 0101 and this is

Hence, it is proved zero minus any binary number is nothing but 2’s complement of this number, hence 2’s complement of any binary number can be represented as negative equivalent of that number. In 2’s complement first we convert a decimal number into binary number system. Suppose we want to represent (5)10 into binary 2’s complement. Binary representation of (5)10 is (0000 0101)2.

Now the interesting fact is that the unsigned form (5)10 into 2’s complement is direct representation of binary form of (5)10 i.e. (0000 0101)2. Unsigned number is treated as positive number. Signed decimal number can be a positive number or negative. Now to calculate 2’s complement for a signed decimal number i.e. (-5)10, we have to find out the 1’s complement and then convert each digit into its opposite digit (i.e. 1 into 0 or 0 into 1) and add 1 at last. This result after addition is the 2’s complete representation of signed (negative) decimal number.

Now look at the chart below.
2’s complement
(+5)10 is same as (5)10. But for (-1)10 it is treated as unsigned (255)10. (-5)10 ⇔ (251)10
Always keep it in the mind that negative 2’s complement numbers are always represented as the binary number in such a way that when added to a positive number of the same magnitude must be zero.
The important thing is to be kept in the mind that the left most bit or significant bit indicates the sign of the integer. It is called the signed bit also.

  • If the left most bit is zero then the number is positive.
  • If the left most bit is one then the number is negative.

Arithmetic in 2’s Complement Method

2’s Complement Addition

Addition in the 2’s complement, it always follows the same rule as it is used in the normally binary addition. Suppose we want to add (8)10 and (-3)10.
First we have to convert them into 2’s complement and simply add them.


As carry is 1 then number is positive. Here carry is 1 and it is out of 8 bits hence is not considered in byte and hence the answer is one byte long positive number. So it is clear that for signed and unsigned numbers addition can be performed easily in 2’s complement.

2’s Complement Subtraction

Subtraction in 2’s complement follows the same rule as it is in the normally binary addition. Only thing is that here subtrahend is first converted to its negative form and then it is added with minuend. Suppose we want to subtract (8)10 from (9)10. First convert (8)10 from (-9)10 into 2’s complement and simply add.



As carry is 0 then number is negative. So it is clear that subtraction can be performed easily in 2’s complement easily.

2’s Complement Multiplication

For 2’s complement multiplication, it always follows the same rules as binary multiplication. Suppose we want to multiply (- 4)10 with (4)10 that gives (-16)10. Now , (- 4)10 = 1111 1100 in 2’s complement and (4)10 = 0000 0100 in 2’s complement

2’s Complement Division

For the 2’s complement division, the method is 2’s complement subtraction repeatedly. First calculate the 2’s complement of the divisor and then this converted divisor is to be added to the dividend. Now come to the next subtraction cycle. Here quotient replaces the dividend. Repeats it again and again up to the quotient is getting too small or zero. If it is not zero then it is treated as remainder. Suppose we want to calculate (7)10 ÷ (3)10, answer gives (2)10 as quotient and (1)10 as remainder. Now let’s start to calculate it in 2’s complement.

As the repetition is in two rounds, then the quotient is (2)10.

Want To Learn Faster? 🎓
Get electrical articles delivered to your inbox every week.
No credit card required—it’s 100% free.

About Electrical4U

Electrical4U is dedicated to the teaching and sharing of all things related to electrical and electronics engineering.

Leave a Comment