# subtracting binary numbers using 2's complement [closed]

Is it usually to not have a carry in the two's complement method for subtracting two binary numbers when we subtract a large number from small one ?

## closed as unclear what you're asking by Anonymous, RoyC, Dmitry Grigoryev, awjlogan, Elliot AldersonOct 17 '18 at 18:32

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Your question is a little vague. Can you show some examples of two's-complement subtraction in binary to illustrate your main question? – Elliot Alderson Oct 12 '18 at 12:33
• Subtraction is just a special case of addition ;-) – vicatcu Oct 12 '18 at 12:35
• @ElliotAlderson I mean , is it usually to end up with a carry after the summation step in the two's complement method for subtracting binary numbers , when subtracting a large number from a small number (i.e Small number - Large number) ? – Ahmed Zalook Oct 12 '18 at 12:37
• @vicatcu , so this means what ? Do we usually end up with a carry or not ? – Ahmed Zalook Oct 12 '18 at 12:38
• It seems like you should be able to answer this question yourself if you tried a few values. Use 3-bit two's-complement numbers and do some subtractions...how often do you get a carry? – Elliot Alderson Oct 12 '18 at 14:02

Carry behaves as if all numbers are unsigned. Just subtract as you were taught in school, i.e. going from right to left with 'borrow':

 4 = 0100
7 = 0111
---- -
1101 with a borrow remaining

7 = 0111
4 = 0100
---- -
0011 with no borrow remaining


Whenever a borrow remains, a binary adder-subtractor will set carry out. It is fairly obvious this will happen if and only if the first operand is less than the second. So far for positive numbers.

So what about negative numbers? As I already pointed out, carry behaves as if all numbers are unsigned. For a negative number, you first need to look up which unsigned number has the same binary representation as the negative number. For example, -3 is represented by 1101 in (4-bit) two's complement. 1101 represents 13 when considered an unsigned number. That means:

• (-3) - 4 gives no carry, even though the first operand is smallest
• 4 - (-3) gives carry, even though the first operand is greatest

In binary:

-3 = 1101
4 = 0100
---- -
1001 with no borrow remaining

4 = 0100
-3 = 1101
---- -
0111 with a borrow remaining


In general, the unsigned equivalent of a negative number in two's complement is always greater than the unsigned equivalent of a positive number in two's complement. So as far as carry is concerned, a negative number is always greater than a positive number. If you keep that in mind, then the answer to your question should be: yes.

You should start by understanding that the negative of an integer value encoded in twos-complement is achieved by inverting all the bits and then adding one to the result. Proof left as an exercise to the reader.

You should follow from that that (a - b) = (a + (-b)). So subtracting b from a is the same as calculating the negative of b and adding it to a. You can get therefore use an adder to achieve subtraction by, when wanting to do subtraction, setting the carry in to 1 at the least significant bit slice and inverting the bits of b.

Going a little deeper, conditionally inverting a bit can be achieved using the XOR gate. That is to say: b XOR 0 = b, and b XOR 1 = /b. Armed with all this information you should be able to see clearly that subtraction can be accomplished by an adder.