- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the subtraction of binary numbers?
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.
Example: 11101011 - 01100110
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.
Example: 10010101 – 10110100
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 0 1 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 1 1 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 +1 1 0 0 1 1 1 1 1 Output = 10011111 (MSB indicates a negative value)
- Related Articles
- What is the addition of binary numbers?
- What is the division of binary numbers in Computer Architecture?
- What are the properties of subtraction?
- PHP program to calculate the repeated subtraction of two numbers
- What is Subtraction Operator (-) in JavaScript?
- 8085 Program for subtraction of multi-Byte BCD numbers
- Give properties of addition and subtraction for whole numbers.
- What is BCD Subtraction in Computer Architecture?
- Program for subtraction of multi-byte BCD numbers in 8085 Microprocessor
- Performing the subtraction operation without the subtraction operator in JavaScript
- Negative Binary Numbers\n
- What Is the Distributive property of numbers?
- What is Binary Decoder?
- What is Binary Adder?
- What is Binary Variables?
