×

Binary Subtraction using 2’s Complement

There are a total of four binary operations; binary subtraction is one of them. The binary subtraction is carried out by applying the subtraction procedure to two binary values (numbers that only contain 0 and 1). The binary subtraction is similar to the fundamental subtraction performed in Maths on decimal numbers. Therefore, in order to reduce the digit by one, we must borrow one from the next higher-order digit when subtracting 1 from 0. The remaining digit is also 1.

The basic binary subtraction is given below:

  • 0 – 0 = 0
  • 1 – 0 = 1
  • 1 – 1 = 0
  • 0 – 1 = 1 (Borrow 1)

Example of binary subtraction:

1010

-101

0101

2’s Complement Binary Subtraction

In 2’s complement binary subtraction in order to subtract two binary numbers, we add one number with the others 2’s complement. In order to get the 2’s complement of a binary number, the given number is simply inverted and 1 is added to the least significant bit (LSB) of the given result.

2's Complement of Positive Numbers is used to represent negative numbers. In binary form, for instance, -8 can be represented as 2's Complement of 8.

Step 1: The first step in putting this method for subtracting two binary numbers into practice is to find the 2’s complement of the number to be subtracted from another number.

For this, first we find the 1’s complement of the number and then add 1 to it in order to get the 2’s complement.

For example, let’ say we need to find the 2’s complement of the binary number 01001(9). We need to find its 1’s complement first. In order to find it, we substitute all 0 with 1 and all 1 with 0. Then 1 is added to it to get the 2’s complement. This is shown below:

Binary number: 0111
1’s complement: 1000
		   +1
2’s Complement : 1001
  • For a negative number, we consider the binary numbers from 0000 to 1111 (base ten's 0 to 15).
  • Respectively, the numbers (0001 – 0111) will represent the positive numbers 1 through 7, while (1001 – 1111) will represent the negative numbers -7 through -1.
  • Numbers are stored in binary form in registers on a computer, where a specific number of bits are reserved for this purpose. There are various sizes of registers. For this example, we will use a register of size 8.
  • Using two's complement, it is simple to convert a negative integer in base ten into binary form.
  • First, ensure that the register you select is large enough to hold all of the bits required to represent the number.
  • In binary form, write the given number's absolute value. If you put 0 before this number, it means that it is positive but if you put 1 before then it means it is negative.
  • By changing zeros into ones and ones into zeros, you can get the complement of each bit.
  • Then, add one to your outcome. The negative integer is represented here using the two's complement.

Example: Determine the 2’s complement of -17.

Binary number:  0001 0001
1’s complement: 1110 1110
	    +            1
2’s complement:  1110 1111

Therefore, here the binary number 1110 1111 is the 2’s complement for -17. Since it starts on the left with a 1, we know that it is a negative number.

Step 2: Add the 2’s complement of the smaller number to the larger number.

Step 3: Exclude the carry. Keep in mind that this case always has a carry.

Example: Subtract (1101)2 from (0111)2 using 2’s complement.

Step - 1: 2’s complement of (0111)2 is (1001)2.

Step-2: Add (1001)2 to (1101)2

		        1101
		      +1001
Omit this carry	       10110
The final answer would be 0110

Advantage of 2’s Complement

When compared to the direct method of subtracting two binary numbers, the 1's and 2's complement methods for subtracting binary numbers appear to be more complicated. However, when applied with logic circuits, both methods have distinct advantages because they allow subtraction to be performed solely with addition. Logic circuits make it simple to determine a binary number's 1’s and 2's complement; The fact that the end-around-carry operation, which is a feature of the 1’s complement method, is not involved in 2's complement subtraction gives it an advantage.


Related Topics

What are the disadvantages of the Internet?

Disadvantages of the Internet Every invention has two aspects, good and bad. However, for all its advantages and positive perspectives, every technology has its obscure and nasty side.  Similarly, the Internet...

5 minutes read.

What is a CSV file?

A plain text file known as a "Comma Separated Values" (CSV) file holds data by separating data items with commas. When data has to be interoperable with a wide range...

5 minutes read.

What is MsConfig?

Microsoft Windows starting issues can be resolved using the system application MSConfig. In Windows Vista, Windows 7, Windows 8, and Windows 10, it is officially called System Configuration or Microsoft...

3 minutes read.

Difference between Hard Copy and Soft Copy

Hard copy: A hard copy is a printed version of a computer-generated digital document file on paper or another transparent medium. The result is physically printed on paper and is...

4 minutes read.

Computer Virus

"The computer virus is a malicious code that replicates by copying itself to another program."  It can destroy a single program or the whole software of the computer system. In...

3 minutes read.

Data Warehouse

It is a system that consolidates the data collected from many sources into a single and central data storage. In basic terms, it is a data repository that can be...

10 minutes read.

What is a Device?

Generally, when we hear this term named "Device", we have a perspective that it may either be some kind of electronic equipment or a machine built to work for a...

3 minutes read.

What is Multitasking?

Multiple programs can be run simultaneously, thanks to this logical expansion of a multiprogramming system. In a contemporary computer system, the word "multitasking" is employed. The ability to multitask in...

4 minutes read.

What is Composite?

Composite can have different meanings depending on the context, but generally, it refers to something made up of multiple parts or elements combined to form a whole. In materials science,...

10 minutes read.

What is a Webcam?

Webcam is a peripheral digital camera that can be attached to the device, which allows you to click photos and record videos directly on the system. There is various webcam...

11 minutes read.

What is an Executable File?

An executable file (EXE file) contains a set of instructions, when the user clicks on the file icon, the system can immediately execute. The file extension for an executable file...

4 minutes read.

How to use a computer keyboard

Alphanumeric, function, control, and arrow keys are on the keyboard. The left hand holds the "asdf" keys, while the right-hand holds the "jkl;" keys. To advance or switch between boxes,...

9 minutes read.

Autoexec.bat and config.sys Information

Basically, the Config.sys and Autoexec.bat files are made for MS-DOS and Windows 3. x to load the device and operating system to work effectively. The most recent versions of MS-DOS...

7 minutes read.

Basic Network Troubleshooting

The term Basic Network Troubleshooting means to determine the issue related to the network through a continuous process and solve them using practically examined and reliable solutions. The methods that...

9 minutes read.

What are Storage Devices?

Computing hardware is capable of storing the information and can also be processed. Information on the storage can be stored permanently as well as temporarily. It is one of the core...

7 minutes read.

What is a TAB stop?

The place where the cursor stops after pressing the Tab key is known as a tab stop. The carriage moves to the next tab stop when you click the tab...

3 minutes read.

Edge Computing

What is Edge Computing? Topics Covered What is Edge Computing?Need of Edge computingBenefits of Edge ComputingPotential industries using Edge ComputingChallenges of Edge Computing We all know about data existing in the cloud, but...

10 minutes read.

How Much is 1 Byte, Kilobyte, Megabyte, Gigabyte, etc?

In this article, we will discuss some of the data-storing units, which are helping to store data in the memory of the device. They are all types of memory units...

6 minutes read.

Internet Explorer Shortcut Keys

While using internet explorer, when we use shortcut keys, our work will be done faster when compared to the job done without using them. The reason is internet explorer is...

23 minutes read.

Computer Hardware

The computer hardware includes the physical parts or components of the computer, such as to monitor, keyboard, mouse, motherboard, etc. We need software for the instructions that can be stored...

5 minutes read.