Understanding subtraction by addition and difference between one's complement and two's complement

1k Views Asked by At

This week our lecturer in microprocessor architecture showed us how the two's complement and the ten's complement can be used to do subtract by doing addition.

For example: 15 - 7

maximalNumberOfTheCurrentRange - numberToSubtract + 1 => 99 - 7 + 1 = 93

Then

  15

+93

===

108 as intermediate result.

Now remove the leading 1. => It becomes the final result 8 !

But how does that work?

I mean: I understand how to do the algorithm. But I would to understand the trick which is used here.

Can someone explain it to me in an easy to understand way?

I would very appreciate it.

I'm not much into academic mathematics I should mention ...

Moreover: What's the difference between the so-called "one's complement" and the "two's complement"?

1

There are 1 best solutions below

3
On BEST ANSWER

1.) In above method -

If we have carry then we can ignore it.

So in 108. Carry digit is ignored and we have 08 as final answer.

See this for reference and example.

2.) I am trying to differentiate one's and two's complement using main advantage of 2's complement. Advantage of two's complement over one's complement is that two's complement only has one value for zero. One's complement has a "positive" zero and a "negative" zero.

Next, to add numbers using one's complement you have to first do binary addition, then add in an end-around carry value.

Two's complement has only one value for zero, and doesn't require carry values.

For reference see this.