Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.
Hai,
Concept binary subtraction is same as decimal subtraction.
In normal subtraction,we use the base as 10, but in binary subtraction, base is 2.
For example, subtract 0x07 from 0xC0.
In decimal, it is 12-7 = 5.
in binary, it is 0000 1100-
0000 0111
Here is the concept of borrow.
For the 0th bit, borrow a 1 from the nearest place. This makes it 10 in the 0th position. So, 10-1=1.
In decimal subtraction, we are borrowing a Ten from the nearest place, while in binary subtraction we are borrowing a Two from the nearest place.
You can also refer 1's complement and 2's complement addition for binary subtraction.
Everything is extremely open and quite clear explanation of concerns. that is truly data for the my ideas.... Your site is really useful. Many thanks for sharing.
Hai,
If we consider an 8-bit system,(just for example), a signed number can represent values ranging from -127 to 0 to +127. In hex,+127 is 0x7F(0b0111 1111) and -127 is 0xFF(0b1111 1111). If the Msb bit is 1,the number is negative and positive otherwise.
So, if we need to subtract 12 (0x0C) from 5 (0x05),
Here, we cannot subtract 12 from 5. So, we cannot borrow a 1 from the nearest position (during subtraction of 4th bit). If we assumes to borrow a 1, then the subtraction will be normal.
But it is better to consider 2's complement for subtraction.
1's complement of 0x0C (0000 1100) is 0xF3 (1111 0011).
2's complement of a number is obtained by adding a 1 to it's 1's complement.
So,2's complement of 0x0C is 0xF4 (1111 0100)
Always take the 2's complement of the subtrahend and add it to the minuend. If the result has a carry, discard it. If the result doesn't have a carry, take the 2's complement of the result and the final result will be negative.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.