Welcome back.
And in this lecture we are going to take a deeper look at subtraction, focusing on entirely on how
borrowing works step by step in decimal numbers.
Now this is important not only because subtraction is fundamental, but also because everything we do
here will directly apply to how subtraction is performed in binary.
Now, computers subtracting binary, but they follow the exact same logical process.
And we are about to see here.
And as always, since we are doing this in a visual lecture, I will go through what to draw on your
notebook to practice on your own.
Now let's reuse our some example numbers that we used previously 67 subtraction 79.
Now let's go digit by digit starting from the right most column from here.
Now this.
As you remember this is ones tens and hundreds and this goes on like that.
Hundreds.
Thousands.
Ten thousands.
Hundreds.
Thousands.
But now we will work with just ones and tens.
Now you have seven.
Subtract nine, which is not possible.
Seven is smaller than nine.
What to do now?
We borrow one one from six which is next digit to the left in the tens place.
When we borrow, that one becomes a ten to add our digit.
So seven becomes 17 minus nine, which becomes eight.
After the borrow, the six we had here in the tens place is now five.
But now we are doing five minus seven again.
It's not possible Since five is less than seven.
So once again we need to borrow.
But this time we don't have a digit to the left to borrow from.
Now in this two digit number.
So we imagine borrowing from zero here or from an implied digit which gives us ten.
And what we will see here 15 minus seven equals eight.
So eight here and eight here.
Now after all the borrowing and the subtraction, we arrive at the digit 88.
But the result needs to be examined carefully.
The value 67 -79 equals eight.
88 is not correct.
The value 8 to 8 here is not the actual result of 67 -79.
It's a number that came out of treating 67 as if it were, as if it were bigger than 79, and forcing
the subtraction to work by borrowing.
In doing so, we completely ignored the most important part of subtraction which number is actually
larger.
But what we do here.
Now we imagine a zero here, one here.
So if we make the six seven.
So what?
500 -88, we get the result.
But that adds another complexity to our arithmetic here.
But it is also a solution.
In this case 12 is the solution.
But we want to get that 12 easily.
There's an easier way.
In the real math we will just change these places here.
So 79 -67.
What now?
Two.
One.
This is positive number.
So the correct result, because we are subtracting a larger number from a smaller number.
So how did we end up with 88 instead of 12.
Which is actually we will just change it to minus.
I will say that we perform the mechanical borrowing without checking which number was bigger.
So yes, the difference in the magnitude is 12.
But our manual borrowing when starting with 67 incorrectly produced 88 here, which as I said, if you
just you remember once tenths and hundredths, if you end here on the left side of six, we have hundreds,
right.
So if you borrow one from the hundreds and 100 minus our result here equals 12 -12.
Again this is just this just adds another complexity to our subtraction.
So we will not use this model in our lecture.
But here is an easier model.
Just change the places with the higher value if you are subtracting higher from less.
And there we are 12 and add just minus here.
That's it.
Then we will write.
The correct final result is -12 here.
Now always compare your numbers before subtracting.
So if the top number is smaller your result will be negative and the borrowing without considering that
will give you a misleading answer.
Which, uh needs another another layer layer of arithmetic here, which is not needed.
Right.
Let's do another example here 60 or 33 -43.
So 33 is less than 43.
So we will change it to three -33 and ten.
And we will just add minus here.
And here we are.
Now this illustrates an important point.
The digits alone don't tell the whole story.
You must always look at the original problem to understand whether your result should be positive or
negative.
In programming and computing, signed and unsigned number representations help enforce this distinction
automatically using flags and bit encoding, which we will explore later.
And this result makes sense.
If you have $67 and someone asks you to give the 79, you are going to be 12 short.
That's what -12 represents in this context.
In programming, the system needs to know this too, which is why things like sign bits and two's complement
exist.
But we will cover this later in this next.
Now, this example emphasizes how subtraction by borrowing focuses on the mechanical part of the operation
while interpreting.
The final result also requires considering which number is bigger, even though we got the negative
result which is expected.
67 is less than 79.
What we really care about here is step by step borrowing process in subtraction.
Borrowing seems like just a classroom trick when you are learning subtraction in school, but in competing,
the logic is at the heart of subtraction.
Circuits work.
When we get into binary subtraction, we will apply this exact same algorithm, which is two digits
zero and one.
And once you understand borrowing, you will also understand how subtraction creates flags in CPU,
just like addition does.
In this next lecture, we will move on to the binary subtraction and you will see how beautifully this
logic carries over.
Let's continue on typhoon and I'm waiting.