Continue to Site

Welcome to EDAboard.com

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.

Can anyone please clear the concept of binary subtraction?

Status
Not open for further replies.

DEV123

Member level 2
Member level 2
Joined
Feb 28, 2009
Messages
44
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,583
Can anyone please clear the concept of binary subtraction? Especially 0 - 1 that is the concept of borrow.

-Devanand T
 

Capture.PNG
Can anyone please clear the concept of binary subtraction? Especially 0 - 1 that is the concept of borrow.
here is the screen shot that will explain you the binary subtraction .....
if still you have doubt then please reply back to this thread



..... happy to help
i_chaitanya
 

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.
 

Chicago Electric Signs

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.



Chicago Electric Signs
 

Can you explain a lower - higher value example, how negative is considered in binary.
 

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),

0000 0101-
0000 1100
-------------
1111 1001 (0xF9.ie, -7 in decimal)

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.

0000 0101+
1111 0100
-------------
1111 1001 (0xF9)

Here, there is no carry. So,take the 2's complement. i.e, 0x07 (0000 0111) and the answer is -7.

Check this also,
http://fullchipdesign.com/2scomex.htm
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top