Hello this is a video on some traction and binary codes.
Subtraction is very straightforward some traction is the same thing as addition Except you just have
to convert the number.
So let's do that.
Which is can my pen up here draw.
There we go.
So if I have the number 13 and I want to say something like 13
minus seven K so 13 minus seven is the question.
So if we want to convert this to binary we could do that.
So let's convert this to binary.
You can say 13 and we can say 7.
Now 13.
I know how to convert to by Americans say this isn't a binary and just do that.
So that's that's what what is minus 7 in binary.
Well what we have to do is we have to get 7 then convert it.
So let's say 7 equals decimal to binary and we get 1 1 1.
OK.
Now what we really need is minus 7.
So let's write out what we have.
So 13 is 1.
This is 13.
Now what is 7.
That's that's.
But we really want at minus 7.
So remember we need four spots here.
That's that's seven with the one in front because we need four response and we're going to flip the
bits and then we're going to add one.
So this equals minus seven.
So now what we could do is we could take this idea and very easily.
Right down minus seven because now we know and minus evidence it's this.
So that's 13 plus minus seven which is the same thing.
These are all the same.
So now if we add these we get zero carry that one.
And now we're going to do that.
Now what do we get.
Now remember k we only are dealing with four bits over here so I'm going to get rid of.
I'm just going to deal with these bits over here.
I'm not going to be dealing with any of the other bits.
Why not.
Well the reason I'm not going to deal with any other bits is because if I'm only dealing in four bits
over here so this extreme it's going to be dropped.
So what's going to happen.
So what's going to happen when I do this.
Well what's going to happen is.
Sorry I don't know what's going on here.
So what's going to happen is I get this.
Now let's see what is this.
Well that's four plus two is six.
Perfect 13 minus 76.
So everything did work out.
You get 13 minus seven and six.
This is six and 13 plus minus seven is what we wrote over here and that is six obviously.
And so therefore we do get to see that everything does work out.
So it seems to me that subtraction is the same thing as addition.
We just need to get the minus have to get the minus We flipped.
Now I'm going to do something called binary codes.
K are going to do something called binary codes now.
Now binary codes is just suggesting something a little bit past these ideas.
This idea of negative numbers right because negative numbers and subtraction is just saying well let's
take a positive number and let's do the procedure that we said we do.
Which seems fine but let's do the procedure that we say we do slightly different.
What do I mean what I mean is that this is
0 1 2.
And now from two I have to put my one over here three and then right.
So you keep going.
Sorry that's for.
Let me switch that.
Whoops.
Who.
That looks like three.
Oh yeah that's right.
Of course four five etc. now.
So that 0 1 2 3 4 5.
The thing is though that.
Who told you that that's the way to do it.
Now we did explain previously that that's very logical but it doesn't have to be that that's the way
to do it.
For instance there's something called B.C the 8 2 4 1 code which is let's just write out 0.
Let's just write out everybody so we're going to put 0.
I'm just going to put an extra spot over here for each of them 5 am I going to do 6 7 8 9 and I'm going
to do 10.
So six is just going to take this and is going to make it into six so it's going to be four to six.
And then this is going to be seven and I'm going to get eight and then I'm going to get nine and I could
keep going it really doesn't matter.
But let's just leave it at that.
OK let's just leave it at that now.
Now when I do this if I say the number 150 in binary I could write it out just like we've done before
you know you get the highest power etc..
But instead what we can also do is we could just write 150.
So for instance 1 and then a 5 and then a zero.
So now it's a little bit easier to decode because that's the one that's the five and that's the 0.
So 1 5 and 0 and that's 150.
So you could write numbers that way.
Well obviously it's going to take a lot more to write numbers that way.
But it's not impossible that that should be you know it's not such a terrible way there's a 2 4 1.
So you know be over there now I'm going to write numbers a different way for it.
So I'm going to write numbers differently.
This is actually called the gray code.
So let me write it.
Let me read it this way.
Let's get another caller here.
And of course this will enhance our lesson here.
1 2 three four zero.
Now one also the same.
Ok as before.
So that's one.
Now two in this is going to be little bit different.
OK.
Why is that too.
Because the gray code is basically that we're only allowed to flip 1.
It's only should be one difference between each number.
It should be easy to get from number to number so if you flip this bet that's two.
Now three is going to be the next logical flip which is their four is going to be the next flip which
is their 5 is going to flip this.
OK.
And then six
K 7 you're right we got that and then we go to the next logical step which is we follow the pattern
which is that we're going to say now we flip this let this first one based on the other ones we get
this.
And now we follow the same pattern.
So that's eight.
So we're going to get nine.
What should 9 be.
We should flip the last one.
What should 10 be.
We flip this one.
What should.
OK what should 11 be.
We turn the last one back to zero.
What should 12 be.
Right.
What should 12 be.
We turn this one to zero because we really did the other one so we flip that.
What should the 13 be OK again from here to here.
From 12 to 13 I'm sorry from from 11 to 12.
This is 11 to 12.
The gray code just slips one.
So we have 13 we flip that 14
and 15 here and then 16 whoops was here and then 16 we are one in front and then you follow the same
procedure.
So you can follow the procedure over here you can follow the procedure.
This is one two three four five six seven eight nine 10 11 12 13.
Whoops.
One two three four five six seven eight nine 10 11 zero you.
It was completely skipping the zero then I'd say it's off by 1.
Wondering why that was happening start we start from zero in binary.
So to give you that again let's pick a line and thickness.
So that's 0 1 2 3 4 5 6 7 8 9 10 9 11 12 13 14 15 K so the pattern holds that if we pick the zero over
here and we flip this if we pick the two with the first three we flip it back.
We get this and the four flips.
Now here's the way the pattern should be.
We flip this and flip the next one then we go back and forth.
This one here this.
And then we go back to the one come over here flip that then go back over here and go back there because
we really did.
1 0 0 because we're just flipping one.
So essentially that's that's the pennon that's a gray code.
The nice thing about it is that it's it's you just flipping one there's one difference between this
if you want to know with 11 or 12 or 13 is that you need to 11 if you know the front of it.
If you know 12 and you want to 11 or 13 just have to flip this or flip this so it's one or the other.
Over here if you want to write so you could know if 12 is.
And to be able to find an even find any number pretty quickly now it's actually pretty easy to convert
to binary.
But it's I guess irrelevant for now.
But but anyway each of these different types of codes instead of using binary you can use like this
and a four to one code or a gray code.
G R A Y gray.
But either of those any of those could be used to encode numbers and we can also use just just assign
something whatever we like so we could assign let's say a question mark we could assign you know something
like this and then we can assign an exclamation points something like this.
And then we can assign a star
something like this you can assign it whatever you want so you could have alphanumeric.
And there's and there's several systems that are out there that are just standards you know don't have
to be even logical at all.
You know the gray code has benefits but doesn't even have to be logical so that's any way some subtraction
and then some different binary codes.