2’s Complement - Uses, Addition & Subtraction

By Priyanshu Vaish|Updated : April 10th, 2023

In 2's complement number system, binary numbers are encoded. The Binary Number System is one of the most widely used number representation schemes in digital systems. There are just two symbols or possible digit values in the Binary System: 0 (off) and 1(on). The positive and negative numbers are encoded in 2's complement number system.

In general, binary numbers have different kinds of complements: 1's complement and 2's complement. Simply invert the original number to get the 1's complement, and the 2's complement is the 1's complement of the given number + 1 to the least significant bit (LSB).

Download Formulas for GATE Computer Science Engineering - Programming & Data Structures

Table of Content

What is 2’s Complement?

A two's-complement number system encodes positive and negative values in binary form. Except for the most important bit, whose weight is the inverse of the corresponding power of two, the weight of each bit is a power of two.

The signed binary integers are also represented by 2's complement. To determine the binary number's 2's complement, first, find the binary number's 1's complement and then add 1 to the least significant bit of it.

Uses of 2’s Complement

The representation of 2's complement is unambiguous, it is highly helpful in computer number representation. A positive number is simply expressed as a magnitude form. So there is nothing to be done to represent positive numbers. However, if we want to represent a negative integer, we must use either the 1's complement or the 2's complement approach.

The 2's complement of binary numbers is used in a variety of ways, most especially in signed binary number encoding and different mathematical operations for Binary numbers, such as additions and subtractions.

Download Formulas for GATE Computer Science Engineering - Algorithms

Addition using 2’s Complement

When we add two binary integers using 2's complement, we can get three different cases, which are as follows:

Case 1: Addition of a positive and a negative number when the positive number is greater in magnitude.

Find the 2's complement of the given negative number. Add the specified positive number to the result. If we receive an end-around carry 1, the number will be positive, the carry bit will be eliminated, and the remaining bits will be the final result.

Case 2: Addition of a positive and a negative number when the negative number is greater in magnitude.

Find the 2's complement of the given negative number. Add the specified positive number to the result. There is no end-around carry, and the remaining bits will be the final result. The resultant is a negative value.

Case 3: Addition of two negative numbers

Find the 2's complement of both the negative numbers. Add these 2’s complement numbers. If we receive an end-around carry 1,  the carry bit will be added to LSB, and forgetting the final result, we will take the2's complement of the result. The resultant is a negative value.

Download Formulas for GATE Computer Science Engineering - Digital Logic

Subtraction using 2’s Complement

The adding an end-around carry-bit occurs only in 1's complement arithmetic operations in 2's complement arithmetic operations. The procedure for subtracting two binary numbers using 2's complement is given below:

(Note: The subtrahend is the number that will be subtracted from another number, i.e., minuend.)

  • Take the 2's complement of the subtrahend.
  • Add with the minuend
  • If the result of the preceding addition contains carry bit 1, it is discarded, and the result is a positive integer.
  • If there is no carry bit 1, then take the result 2's complement, which will be negative.
Important Topics for Gate Exam
Brittle MaterialCapacitors in Parallel
Capacitors in SeriesCarnot Cycle
Cement TestClamping Circuit
Clipping CircuitCMOS Fabrication
CMOS ConverterColumn Base

Comments

write a comment

FAQs on 2's Complement

  • Two's complement is a mathematical operation that converts a positive binary number reversibly into a negative binary number of comparable value, utilizing the binary digit with the highest place value to know whether the binary number is positive or negative.

  • The 2s complement of -5 is as follows:

    The binary of 5 is 0101.

    Now, find the 1’s complement of 5 as 1010.

    For 2’s complement, add one to the above result

    = 1010 + 1

    = 1011

  • Simply invert the given number to get the 1's complement of a binary number. Simply invert the provided integer and add 1 to the result's least significant bit (LSB) to get the 2's complement. The binary number 110010 1's complement is 001101. The binary number 110010 has a 2's complement of 001110.

  • The binary number 2's complement is implemented in a variety of ways, most commonly in signed binary number encoding and other binary number mathematical operations such as additions and subtractions.

  • The procedure for subtracting two binary numbers using 2's complement is given below:

    • Take the 2's complement of the subtrahend.
    • Add with the minuend
    • If the result of the preceding addition contains carry bit 1, it is discarded, and the result is a positive integer.
    • If there is no carry bit 1, then take the result 2's complement, which will be negative.

Follow us for latest updates