×

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

How to open the Windows My Documents or Documents folder

Documents or My Documents (known in earlier versions of Windows such as Windows XP) is basically an in-built directory provided by Microsoft Windows. This is a very valuable directory that...

5 minutes read.

What is SAN?

A storage area network, sometimes known as SAN, is a specialized, quick network that provides network access to storage devices. Hosts, switches, storage components, and storage devices make up standard...

7 minutes read.

How to Password Protect Files and Folders in Windows?

To ensure the security of your files and folders, it's a good idea to password-protect them, especially if you share your computer with others. Although Windows does not include a...

8 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.

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.

RAM (Random Access Memory) Vs. ROM (Read Only Memory)

RAM (Random Access Memory) Vs. ROM (Read Only Memory) There are several differences between the Random access memory and read-only memory which is given below: RAM (Random Access Memory )ROM (Read Only...

4 minutes read.

What is Case Badge?

A case badge is a small label or symbol fixed to the outside of a computer case, typically on the front panel that displays the manufacturer's name or logo. Some...

6 minutes read.

What is Operating System?

Operating System An operating system is an interface between a user and computer hardware. The operating system's main aim is to provide a suitable environment to a user so that a...

11 minutes read.

What does Alt+R do?

Alt+ R The Alt button is adjacent to the spacebar in the keyword. The Alt key is used with many other keys to perform various functions. When the user uses R...

4 minutes read.

How to associate a file with a program?

How to associate a file with a program in Windows? By default, a particular program is selected by the Windows to open each file type, but you may re-associate a file...

4 minutes read.

What does Alt + O do?

Alt + O is used for opening the Format file menu. Alt + O is a shortcut that can be used by pressing the "Alt" and "O" keys. As shown in...

4 minutes read.

What does Alt+D do?

Computer keyboard shortcut keys play an important role in the working of any computer user. We can do anything from the mouse and keyboard, but shortcut keys provide data in...

3 minutes read.

Where can I ask questions on the internet?

The internet is a great resource of knowledge and information where you can find all types of questions like imaginable questions, past answers, and much more. However, there are times...

6 minutes read.

Where can I find free online virus scanners?

There are many free online virus scanners available on the Internet. They can be download without any cost. Then the users can directly get the service done by the company’s...

3 minutes read.

Parts of Computers Names, Definitions and Images

Computer: A computer is an electronic device, which is made up of using various hardware. The computer processes data, performs calculations, and communicates with other devices and systems. Hardware refers...

14 minutes read.

What is the svchost.exe file used for in Windows?

Svchost.exe is a crucial Windows file that loads the DLL files necessary by Microsoft Windows and other programs that operate under Windows on your computer. Multiple Windows services can share...

8 minutes read.

How to Open Safe Mode?

The Safe mode is a diagnostic mode in Windows that starts the operating system with a minimal set of drivers and files. It is designed to help troubleshoot and fix...

10 minutes read.

What is Ray Tracing?

Ray tracing is a technique used in graphic design to produce graphics by following the route that light follows via individual pixels. The effects of light rays on the items...

4 minutes read.

What is a Slide?

A slide is typically a single page of a presentation or lecture. Slides are usually used to present information visually, using text, images, charts, and other media to convey ideas...

4 minutes read.

What are the advantages of the Internet?

Advantages of the Internet What is the Internet? Today’s world is connected through an internet so that imaging a day without the Internet is like a scary nightmare. The Internet is one...

6 minutes read.