In this video I'm going to show
you a different way of using
this complement notation pending
on which method makes more
sense. Which method is easier
for you? You've got the choice.
Doesn't matter which method you
use, so just to recap why we're
doing the twos complement
notation that this is one way to
represent negative numbers in
the binary number system. And
again to recap, if the number
starts with a zero in the twos
complement notation that we know
that this is a positive number.
And if a number starts with N1,
we know that this is a negative
number, so the 1st digit in the
twos complement notation is used
for the sign bit. Therefore
there's a limitation. So
depending on how many bits you
using for this compliment
notation, we can only use one
less bit for building the actual
numbers. So again, just to
recap, in case you haven't seen
the previous video, every single
number. In the two complement
notation have to be used at a
fixed length, so you can't talk
about, just generally the twos
complement notation. You always
have to say what length of bits
you talking about, so you can
talk about the four bits twos
compliment. You can talk about
the 7 bits this compliment, or
you can talk about the 22 bits
2's complement, but you always
have to give whoever reads
numbers the length, the fixed
length of the numbers. Otherwise
the deuce complement notation.
It doesn't necessarily work, so
this second method is slightly
different from the previous one,
but the answers will be the
same. So in the previous method,
we converted and then we kind of
inversion process. In this
method we also using something
similar, so step one.
Again, we will be to convert.
Into binary.
But then Step 2.
Would be just a simple
inversion.
So we don't have to do
anything like copying bits
or whatever. We just invert
all of the digits, but then
comes on next tab.
And that is odd.
1.
And I'm going to show you
why this is working and how
we can do this, but let's
look at an exact example.
So what would be negative four
in four Bits 2's complement? OK,
so step one.
Convert so again, we're using 4
bits.
1248
and four is just
100. And don't
forget we need the
zero first here.
OK.
Then Step 2 is the invert.
So what happens here then
everywhere I have got a zero, I
turn it into your one and
everywhere when I have a one, I
turn it into a 0 so zero become
one and one becomes zero. And
then comes the extra step.
Is the adding one so one?
1 + 1 makes 0.
Carry the one 1 + 1 makes
0 carry the one 1 + 0
makes one and one plus
nothing keeps one, so minus
four is the same as 1100 in
4 bits 2's complement.
So let's look at minus six and
again converted using the four
bits to complement, so step one
convert. So 4 bits on using
1, two for an 8 and I know
that the six I will the
negative six. I will be able
to show because it's less
than 8, so six is 4 + 2.
And again I need the rest
of the zeros and I need to
0 here as well because I'm
talking about four bits 2's
complement, then Step 2.
Invert.
So zeros becomes ones
and ones become zero.
And then the last step.
Is plus one so one comes here
and I just need to add them
together. 1 + 1 makes 0 karida
one 1 + 0 makes 1 zero plus
nothing is 01 plus nothing is 1,
so minus six is the same as 1010
in 4 bits. This compliment now
don't forget that this is not
the same as 1010.
Just as an ordinary binary
number. So if you just look at
this from context, it needs to
be cleared. If it's a compliment
notation, or if it's just
ordinary binary notation,
because depending on the
difference between complements
and ordinary numbers when you
trying to convert it back into
to find out the decimal
equivalent, you would do
different process is.
Let's look at another example.
So what is 7 in five Bits 2's
complement notation? So 75 bits
2's complement. Now this is a
positive number, so when it's a
positive number I don't need to
do the inversion process. So
again, just like in the
previous video, positive
numbers are the easy examples
because all we need to do is
just step one the conversion.
So the place values again, we're
using that 5 bits, so make sure
that you using order 5 bits 124,
eight, 16 that's all 12345 bits.
Then, which one of these do we
need to be at? 7 again? 7 is 1
less than 8, so I will need to
use every single digits that are
less than 8. So 1 + 2 + 4 makes
7 altogether, but because it's 5
minutes to complement notation,
I need to put the zeros in front
of it. So positive 7 is the
same as 00111 in five bits,
this complement notation.
Now how can we do it the other
way around? So let's say that
you are given a number 10011 and
you are told that this is a 5
bits 2's complement notation
number. So how can we find
out what number is this one
now? Remember that we went
from when we went from
decimal to binary, viewed
under conversion. Then we
done the inversion and then
we done the odd one. So when
you've got the binary
equivalent and you want to go
back to the decimal, then you
have to do that step by step
going backwards. So the Step
1 first here be.
Take away one. Let's do that
now. So 10011 I need to take
away one. One takeaway one is
0. One takeaway, nothing is 1
zero takeaway. Nothing is 00
takeaway, nothing is zero and
one takeaway zero is 1 so
that is the first stage. Then
remember that the middle step
was.
The inversion, So what I need to
do now I need to invert this
number so zero becomes 11,
becomes 00, becomes 10, becomes
one and one becomes zero, and
this is the ordinary binary
equivalent of this 5 bits 2's
complement an. Now what I can do
is do the last step.
Which in this case will be
the conversion.
So just put the place values on
top of the number.
8 + 4 + 1.
That makes 13, so this number is
the equivalent is minus 13 OK
and we have done this conversion
in the previous video, so you
can double check there and
convince yourself that this is a
correct way of doing it.
So look at one more example
01011. This is again A5 bits.
Two's complement notation.
Now again, this is a positive
number because it starts with
zero, so therefore this number
has not gone through the
inversion, and adding one
process. So when I see a number
like this, I know it's going to
be an easy calculation because
all I need to do is just one
step and that is the conversion.
So how do I convert this
number back to ordinary
binary? Let's just copy
this one down here again.
And the easiest and quickest
way, at least for me, is to put
the place values on top.
And then just add those numbers
together. So 8 + 2 + 1 makes 11,
so this number is positive 11.
So let's look at a couple of
eight bits to complement
examples because that is quite
widely used. So how could we
represent minus? 94 in eight
Bits 2's complement.
So remember step one good. It's
a negative number. I need to go
through all three steps. Step
one will be conversion.
So 8 bits 124
eight 1630 two 64128,
so 12345678 different bits
to represent my number.
So I need to
build up 94 so.
64 I'm going to use and the
difference between 94 and 64.
It's a handy 30, so the next
step is how can I build up 30
from the rest of the digits? Now
32 is too big because I'm only
need 30, so the next biggest
place where you can use is 16,
so it takes 16 away from this
and the remainder is 14.
I can take eight from the 14.
The remainder is 6 and six is 4
+ 2 even number, so I'm
expecting the last bit to be 0
and it is because I'm not using
the one and again, don't forget
that you always need to make
sure that if there are empty
spaces before your number, you
need to fill that in with zeros
to make sure that your number
is 8 bits long. OK, so that was
first step, the Step 2 then was
the inversion.
So what we need to do now,
invert every single bits to the
opposite, so zero become one,
one becomes 0.
So zero becomes 11, becomes
zero and zero become one.
This is the inverted number.
But what happens now?
Is I need to add 1. OK,
so let's just copy the
number down here again.
An other one to it.
1 + 1 is zero karida one 1 +
0 is 1.
And from here on I don't
need to add anything, so
I can just copy them.
So the edmister is binary
equivalent of minus 94. Is this
number now? You might ask
yourself a question that you
know when I'm adding binary
numbers together, sometimes I do
have to do loads of carrying.
And what happens if I carried
this number over? So what
happens if I needed to add 1 to
it and then I need to carry it?
Well, that. Extra bit here would
be called the overflow.
And what the computer does is
just simply ignores it. So if
after the addition you end up
with a 9 bits long number, all
you need to do is ignore the
first bit and your answer will
be just that 8 bit.
I hope that you now understand
how the Two's complement
notation works, and I encourage
you to try out the practice
questions that will follow and
you can check your work by
looking at the answers for this
video. We will have two sets of
questions. Here are the
first set.
This is the answer
to the first set.
Here is the 2nd set.
And here are the answers to
the second set.