Hey, guys, what's up?
So in the last video, we learn how those two numbers are stored, how those are stored and how my floating
point numbers are stored.
So in this video, we will learn how negative numbers are stored.
For example, I have four bytes of memory space and here's my data.
I want to find what is the largest and what is the smallest number that I can store.
I want to find the value of A and B.
OK, so for simplification, let's say let's say I have four bids.
That is half a bite.
So I want to find the value of A and B for four bids.
OK.
So, OK, so what does the largest number that I can store.
Obviously when, when, when and when that is plus seven.
And what is the smallest number that I can store and for.
Zero zero zero and zero net is zero.
OK.
So if I followed this presentation, the maximum value that I can store is plus seven and the minimum
value that Igen stories zero.
OK.
But there's a very major problem with this approach, and the problem is we have never done.
But also we have minus 10, we have minus eight.
We have minus seven.
We need negative number also.
So how does two negative numbers.
So let us talk about the first approach.
OK, so the first upload sees what is the difference between then and minus 10?
This is the only difference you will see and be right then and they will put a negative sign.
OK.
So what do we do if I if I have four kids?
I will use my first word as a sign, but if it is when my number is negative.
If it is zero, my number is positive and remaining, Tibbits will be used to find magnitude.
Okay, so in this way, our problem will be resolved and we can and we will be able to represent negative
numbers also.
Okay, so let's see what is the largest and what is the smallest number.
So for finding the largest number.
I have four bids.
First of all, I just number will be positive.
So the first bid will be zero and the remaining three bid all will be won.
To maximize the magnitude.
So this is plus seven means positive and religious.
My list number two can store.
So I have four bids for a small listener.
But what will I do?
I will make my first bid when that is negative number and I will maximize the manged.
That is when, when and when.
So this is seven.
My number is negative.
So this is a business minus seven.
Now, what is our range?
Our ranges from minus seven to plus seven.
So obviously this approach is much better than our previous approach.
Why?
Because in this approach, we are able to store negative numbers also.
But there's a problem with this approach also.
And what is the problem?
OK, so tell me, what does this number.
So zero means?
My number is positive.
And this represent zero.
So my number is plus zero.
Now tell me, what is this number?
So one means my number is negative.
And this represent magnitude.
So my number is minus zero.
So you can see here there are two representation of zero zero and minus zero.
OK.
So there is ambiguity in the representation of zero.
And we will resolve it.
So how we can resolve it.
What we will do.
OK, so how we can resolve it.
What we will do.
We will do some minor changes for positive, no representation.
We will follow the above approach that is signed.
But the first word will be used to assign it.
And the remaining bits will be used as magnitude.
So positive.
No representation.
I will use the above approach for negative numbers.
We have something called to complement.
Those compliment form.
OK.
So negative numbers are represented in those compliment form.
Now, what is to this compliment?
So it does compliment is actually once compliment.
Plus, when and how to find device complement, which is very simple, you just flip all the bits,
flip all the bits of a tiny number, and what you will have is called Wendt's complement.
OK, so let's see some example.
For example, I want to store minus two.
So what do we do?
First of all, we'll be right.
Plus two.
Plus two is zero.
First bit positive and then magnitude, which is zero, one and zero.
So this is blessed to now find one's complement, which is flip all the bits.
So when one is zero and one NARVO finding to complement what you will do, you will add a plus one.
So here you will do plus one.
So my answer will be one.
Plus one.
OK, so before moving forward, let's see one more thing.
What is Zeo Clezio in binary?
Zero.
What is a zero plus one in binary?
One.
What is one plus zero in binary one.
So up to this, my binary and decimal both housein but one plus one in binary is equals to.
This is the most important thing that you have to learn.
That one plus one in binary is ten.
Again in decimal one plus one is true, but in binary one plus one is ten.
OK, so let's see some example of those complement.
For example, you want to store minus two.
So what you will do.
First of all, you will write plus two.
So zero.
And then I am to present magnitude, which is zero one and zero.
So this is plus two.
Now you will find vice complement and whatever else compliment.
Just flip all the bits.
So when one zero and one.
So this is W complement.
Now for finding booze, complement what they will do, you will add one.
So plus one one plus one is then when Gary, when blessed, always one.
Then one.
And then one.
So this number represent minus two.
OK, so this number represent minus two.
OK.
Let's do that.
He was given.
When, when, when and zero.
So you have to find what this number is present in decimal.
OK.
So how we will do.
So we will check.
First word is negative.
So my number is going to be negative.
And for finding magnitude, what do will do?
You will find two complement of this number.
So it is a toothcomb.
Does this number find a nice compliment?
Zero zero zero one and one.
So one plus one is.
When Gary here.
One zero zero.
So what is the magnitude?
Magnitude is two.
And the number is negative.
So this number is minus two.
Okay, so if it was zero one one zero.
So zero means.
This number is Piloto then for finding magnitude.
You will not calculate to complement.
I calculated to compliment here because the number was negative and negative numbers are stored in those
compliment form.
That's why for finding magnitude I calculated boose complement.
But says the number is positive.
This Tribbett will represent magnitude.
Okay.
So this represent magnitude and it is four plus two six.
So this number is plus six.
And this number is minus two.
Okay.
So how we can prove that this number is minus two.
So let's see.
Okay, so let's do some vectors.
Okay.
Suppose you want to find what is five minus five.
So what do we do.
Five plus two is complement.
Of faith, actually, there is nothing called subtract.
There is nothing called septet logic circuit in computer system.
We always have ideologic circuit because at our function at the logic circuit, then can do the work
over subjective logic circuit and hence our hardway we reduce so will reduce the cost.
So what is the five?
Five is first spread will be zero and it will hurt the remaining three birds will represent magnitude
one zero one.
So this is plus five.
Now we're finding does compliment of five.
What will I do?
I will, first of all, write five.
Then find ways complement, which is one two two one zero.
Then I will find to complement.
Which is add one to the last position.
One one zero and one.
So this number is minus five.
Now we will add.
OK.
So zero one zero one one zero one and one.
So one plus one is then when Kerry one plus one is then one carry one plus one is then when ghetty one
plus one is then when Gary and vividly discarded.
OK, so we will discard it.
So this is zero.
OK.
So five minus five should be zero and my for this coming out Billy.
Zero.
Let's see one more example, suppose you want to calculate.
Seven minus seven.
And there should be zero.
So seven minus seven is same as seven.
Plus two is complement of seven.
So four representing seven, four squared will be zero.
And that meaning tribute will be one for to complement of seven.
Will Villedieu.
I will first of all.
Right seven find a complement one zero zero zero then those complement add one.
So one zero zero one.
So this is minus seven.
Now add plus seven with minus seven.
So one plus one is ten.
When Gary went plus one new spin when gay one.
Plus one.
Then when Gary.
When plus minus 10.
When Gary and we were discarded.
So this is my answer.
That is zero.
So I hope by this time you'll know know how to find those complement.
One last example.
Suppose you are given this number one zero zero one and the second number is zero zero zero one.
So this number means zero means.
My number is positive.
Has done the most positive.
Remaining list will represent the magnitude that is Mangere is one.
So number is plus one.
Now, in this case, first bid is when it meets.
My number is negative.
So for finding magnitude, I will find it to complement.
To complement.
So what that do is complement of this number.
One zero zero one find one's complement.
So one's compliment is zero one one zero.
Now for finding does compliment add one plus one.
It is zero one one one.
So what is the magnitude man this coming out to be?
Seven.
So the number is negative.
And the main dude is seven.
So this number represent minus seven.
Okay, so now let's come back to our problem.
Our problem was zero was having two representations, zero and plus zero.
OK, so let's see.
Zero means my number is positive.
And this represent zero.
That means my number is below zero.
Now, in our previous approach, this by any number was representing minus zero.
Now let's see what this number will represent.
And to compliment from.
So one means my number is negative.
And hence numbers negative.
I will calculate my man, do my calculating lose complement.
What is there to compliment of this number whose compliment is, first of all, one's compliment, which
is zero one when one?
Now, for finding those compliment, we will add plus one plus one one plus on this 10, one getti one
plus one is then when ghetty one plus one is then one ghetty when president is zero sorry one.
So this is my magnitude.
That is it.
Okay, so that number is negative and the magnitude is eight.
So this number is minus eight.
OK, so this number is minus eight.
Now, something very interesting happened here in our previous approach.
My range was minus seven, two plus seven.
But falling the does compliment form does compliment approach.
My range has been increased from minus eight to plus seven.
And why this happens?
Because in this case, zero was having to do presentations plus zero and minus zero.
And in this case, minus zero is representing minus eight.
So that's why there is an increase in the range.
OK, so my final ranges, minus eight.
Two plus seven.
It is four forwards.
That is we can right.
Minus two to the power four.
Minus one.
Twittered about four, minus one and here minus one.
So this is so Forbert now we can generalize it for Edwards.
So if I'm having Edwards, my range will be minus two to the power and minus one to.
Due to the power and minus one minus.
OK, so let's see.
Four characters.
I have one bite that is Edwards.
So it is a range of characters.
The range of this will be minus two to the power and seven to go to about seven.
Minus one.
That is minus one.
Twenty eight to one.
Twenty seven.
And we all know nine to five represent a night.
Sorry, 97 represent Smally.
Ninety eight represent.
Be 65 percent.
Capitally.
And so on.
And voting.
I am having to do two bits.
So for integers.
I have to do two bits.
That is my range will be minus two to the power 31 to two to the power 31.
Minus one.
Okay.
So this is the range of integers.
OK, so this value is close to 10 to the Bauer nine and this value is close to the end of the ballot.
Nine minus 10 to the Bauer nine.
So, in short, you can remember that if I am having nine digits in a number, if there are nine digits
in number, that number can be stored in and the other type.
And similarly, if we have long, longer to type in loan order type, I have 64 Edwards because it is
of a debate.
So my range will be minus troupers, about six to three to the power, 63 minus one.
So this is close to 10.
To the power 18.
And this is close to 10.
To the power minus 10.
To the power 18.
So that means if I am having 18 digits against door, that number in long, long is that number of digits
are less than Oracle's 218.
But if the number of digits are less than Oracle is to nine, I can store it in and I can also store
it in long, long time.
But we can also store in integers.
So if there is a number having more than 18 digits, it is a number having more than 18 digits.
I can not store it.
Okay.
It cannot store it.
Longlong cannot store it.
Okay.
OK, guys.
So this is it for this video.
Thanks for watching.