- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

Binary numbers are subtracted by performing two’s complement on the subtrahend. Two’s complement is done through the following steps −

- Complement every digit. That is, change 1 to 0 and 0 to 1.
- Add 1 to the output.

The following example illustrates the subtraction operation of binary digits using the above-mentioned steps.

The second value 01100110 is to be subtracted from the first value 11101011.

First apply two’s complement to the second value 01100110, i.e., follow the two steps as shown.

Step 1: 0 1 1 0 0 1 1 0 1 0 0 1 1 0 0 1 (change 1 to 0 and 0 to 1) Step 2: 1 0 0 1 1 0 0 1 +1 (add 1)1 0 0 1 1 0 1 0(resultant) 1 Then, add the resultant to the first value. 1 1 1 0 1 0 1 1 (first value) +1 0 0 1 1 0 1 0 (resultant)1 0 0 0 0 1 0 1(output) ignore 1 1 1 1 1 1 The output is 10000101.

It can understand the process of subtracting smaller number from larger number. The Most Significant Bit (MSB) or the leftmost bit is set to 1 to indicate a negative number. The MSB is known as the sign bit. The remaining 7 bits are used to express the value.

The following are the steps to subtract a greater number from a smaller number −

- It can apply two’s complement to the smaller number.
- It is used to add the resultant value to the smaller number.
- It can change MSB to 0.
- It can apply two’s complement to the resulting number.

MSB indicates a negative value.

Step 1: 1 0 1 1 0 1 0 0 (greater number) 0 1 0 0 1 0 1 1 (change 1 for 0 and 0 for 1) 0 1 0 0 1 0 1 1 +1 (add 1)0 1 0 0 1 1 0 01 1 Step 2: 1 0 0 1 0 1 0 1 (smaller number) +0 1 0 0 1 1 0 0 (add the resultant value to smaller number)1 1 1 0 0 0 0 11 1 1 Step 3: 1 1 1 0 0 0 0 1 0 1 1 0 0 0 0 1 (change MSB bit to 0) Step 4: 0 1 1 0 0 0 0 1 1 0 0 1 1 1 1 0 (change 1 for 0 and 0 for 1) 1 0 0 1 1 1 1 0 +11 0 0 1 1 1 1 1Output = 10011111 (MSB indicates a negative value)

- Related Questions & Answers
- What is the addition of binary numbers?
- What is the division of binary numbers in Computer Architecture?
- What is Subtraction Operator (-) in JavaScript?
- PHP program to calculate the repeated subtraction of two numbers
- What is BCD Subtraction in Computer Architecture?
- 8085 Program for subtraction of multi-Byte BCD numbers
- Performing the subtraction operation without the subtraction operator in JavaScript
- Program for subtraction of multi-byte BCD numbers in 8085 Microprocessor
- What is Binary Decoder?
- What is Binary Adder?
- Negative Binary Numbers
- C Program for subtraction of matrices
- JavaScript subtraction of two float values?
- What is the use of MySQL BINARY keyword while performing string comparison?
- How to find the product of two binary numbers using C#?

Advertisements