Hi and welcome to the new lesson.
Today we're going to talk about bits and.
What they mean, bits are used to represent data, bits are grouped in bytes, eight bits form a byte.
Bits are the smallest increment of data on a computer.
They are usually referred to as either on and off.
Which is very common, especially in an electrical engineering major or in the normal binary digit notation
of one in zero.
It's funny, but people say about other people that their binary if they can't really.
Do anything in between things need either.
All or nothing?
Now the bigger picture bites.
So eight bids can be grouped together to form KiloByte Megabyte Gigabyte Terabyte, and you can actually
go ahead and deduce how many bids are in each one of these measuring units by multiplying the bytes
by eight.
Inbuilt significance, this is very important because you'll be using it a lot and.
The bit that you have to them most right here, that is the least significant bit.
And as it was, you go more to the left, the bits gained more significance.
And this gets tied in with the next slide you're going to see in which you see the corresponding powers
of two for each bit location inside a binary number.
For example, this binary number one one one one one one one one has eight bits and the the least significant
bit.
It's tied to two to the power of zero.
And as we move more to the left, this one gets tied in with the two to the power of one.
And the third one with two to the power of two.
And so on until we get to the last one, which gets tied in to with the two two, the power of seven.
And this one, as you can see, holds more value, more decimal value in these than any of the other
bits.
So here this is probably where you'll visualize this more is because we get to actually calculate how
to turn a binary number to decimal, so we have the same example one one one one one one one one.
What you have to do is look in this table and say, OK, my number, this is my number here, starting
from the least significant bit on the right.
I say one times, two to the zero plus one times two to the one plus one times two to the two plus one
times to the power three plus one times to the power of four plus one times to the power of five.
And you can actually follow along here two plus one times two to the six.
But this is where it came from.
This table plus one times two to the power of seven.
Now, if you actually perform the calculations, you will see that this number is equal to 255.
And we'll take another example this time is the binary number one zero one zero one zero one one.
And we'll do it the same way, so to find out the decimal value of this will have to.
First, like, do the multiplication between this one and two to the zero, then add the multiplication
between the.
Bit here.
And the two to the power of one plus zero times, two to the power of two plus one times three to the
two to the power of three plus zero times two to the power of four plus one times to the power of five
plus zero times to the power of six plus one times two to the power seven.
And now we've performed the calculation and we find out that the number.
In decimal base is 171.
Normal notation for binary is a zero B in front of the number, but another use notations are the one
that I have here on the bottom, where you just add a b at the end of the binary numbers c see here.
We grouped this number into Nemours because it's easier to visualize for us humans, but in computer,
in inside a computer like you won't have those spaces.
And to turn a decimal number into binary, I like to start by dividing this number.
I'll take this example number one.
Thirty seven.
And now divided to two.
The result I'll market down here is sixty eight.
And then I also take a note of my remainder.
Very important.
And then I take my result in nine divided by two.
My result of that division is 34 and I have a remainder of zero.
Now I divide thirty four by two and my result is 17.
My remainder is zero.
I divide 17 by two and my result is eight and my remainder is one.
And I divide eight by two.
My result is four and my remainder is zero.
Now I have four divided by two.
My result is two and my remainder is zero two, divided by two is one.
And in this case, I'll just move the one over here.
And this is what gives us the binary number from the most significant bit here to the least significant
bit.
So this is very important.
You have to actually write down the result of this operation in this order.
Top to bottom to top.
So we would say one thirty seven in decimal is equal to be one zero zero zero.
So from here, one zero zero one once again, I have separated my bits into nibbles just to make it
easier to read.
So if we want to turn this binary number one zero zero zero one zero zero one back to decimal, we know
its value.
It's one thirty seven.
But how do we get to that value?
Well, we have to use the table that I have presented in the previous slide.
And you multiply each bit with the corresponding power in the and binary table and you add it with the
next byte multiplied, but with its corresponding power of two and so on.
We do with all the bits, and then we perform the calculations and we get a result of one thirty seven.
So the next base we're going to talk about is Hexadecimal also called this base 16.
It does use 16 characters to represent the bids.
So these are numbers from zero to 15.
Zero to nine is represented as we normally know it.
But 10 to 15 are represented by the first six letters in the alphabet.
So 10 is a 11 is B, 12, A C, 13 is D, 14 is E and 15 is F.
And here I have the table of conversion for all the hexadecimal characters.
Zero one two three.
As you can see all the way to F.
And you'll be using these to convert.
All the hexadecimal expressions, too binary.
That's very important.
Now also, I want to point out that the known notation for hexadecimal is zero x, as you can see here,
zero zero zero.
You should use this to distinguish.
A hexadecimal notation or no from another.
Any other base like base 10 that doesn't have anything in front of it or binary or octal?
OK, so now we're going to take concrete example and we're going to try to turn it into binary notation
step by step.
So we have X DeaDBeeF, the very popular cybersecurity example that everybody talks about or likes to
use.
So what we're going to do is we're going to go left to right and translate each one of these characters
hexadecimal characters into their binary correspondence.
But you can also start a right to left.
It doesn't really matter as long as you keep translating them one by one and you put them in the position
where they're supposed to be put the conversions like one after another.
If you start left to right or you put the conversions like in front, if you start from right to left
right, so you'll translate F and then you'll translate E and you'll put it right in front of the translation.
For F, it's important to keep the order.
So D will be b one one zero one e is or B one one one zero e is one zero one zero and so on.
And now we have the final expression for dead beef in binary, and it's a very large number.
So let's say now that we need to convert this number from binary to hexadecimal, and we have no idea
what this would be like.
It is very important to look from the least significant bit here.
Towards the most significant bit here.
And split it into nibbles.
Right.
Leave one space in between four bits, you always start from the least significant bit here.
Group them into four.
Right, so now this expression happens to be an exact number of nibbles, but sometimes you have like
one left over here or two.
And that's not an issue, just pad with extra zeros in front of them to create and nibble.
If that is the case.
So now, once you have it all split into Nemours, you can do the same thing.
You either like start converting them one nibble at a time from the right to from the right to the left
or from the left to the right.
It doesn't matter if you already have them all separated into nibbles in the order that they're supposed
to be.
So one one zero one is the one one one zero is E and use the tables for this, as it's very common to
just make a tiny mistake on one of these expressions thinking that, you know, then I do it all the
time.
One one one zero one one one zero one one is a one one zero one D. And so on.
Now we have the full expression of that beef.
So now let's talk about how to convert text to decimal.
And remember, from binary, we were using the table of correspondence.
So basically each one of these characters is used to represent a power of 16 because this is base 16.
So as is representing the 16s to the zero that we have in this hexadecimal number E represents the sixteen
to the power of ones that we have.
E represent the 16s.
Now, sixteen to the power of two and so on, so we're going to do exactly the same thing that we have
done for the binary.
Expressions.
So we're going to go start here.
The least significant character, and we're going to say f times 16 to the zero because you can see
here plus e!
Time 16 to the one.
Plus, E times 16 to the second.
Plus, B times 16 to the third and so on, you go and add all of these multiplications.
And if you do the calculations, you'll see, you'll see that this is the number used to represent that
beef in base.
10.
The very large number now remember that f e b, all of these letters are just used to represent the
numbers, you know, 10 to 15.
So each one has a correspondent.
F is 15.
That's why I do this here e is 14 and so on.
The last base that I will touch base on today is octal, which is base eight.
There are two notations that are not as utilized here, so either you put a zero in front of the actual
number or you put a cue after the actual number.
However, this one is the most popular.
It's zero lowercase.
Oh.
So when base eight, you have eight characters, you have zero one, two, three, four, five, six
and seven.
And each one of these octal characters gets represented in binary by using three bits.
So zero in octal would be binary zero zero zero one and octal would be binary zero zero one two in October
will be binary zero one zero and so on.
So this is something that you could keep handy if you are performing some actual conversions.
So I'm going to take this example here six seven zero in October base eight and we're going to try to
convert it to binary and the same as I did for hexadecimal works here, too.
I just take each character.
From my octal, no, and I turn it into its binary version.
And I just write them in the same order.
As they are in the actual number and and when I'm done with that, this here gives me my binary notation
for the actual number six seven zero.
So binary, that's one one zero one one one zero zero zero.
And if you want to turn a binary number two actor, I recommend you start from the right and go to the
left, grouping the bits three by three and then you perform.
You convert each group of three bits into an actor character like you hear one one two zero is six one
one one is seven and zero zero zero is eight.
Is a zero sorry, so if you want to turn that an actual number to decimal?
I took this ridiculously large number, but you you will use this table just like we did for binary
and for hexadecimal.
Each character in the actual number gets a power of eight.
That corresponds to it.
So keeping that in mind, the actual number two one three one zero four six zero and transformed into
decimal would be seven times eight to the zero plus six times eight to the one plus four times eight
to the second, plus zero times eight to the third plus one times aide to the power of four plus three
times eight to the power of five plus one times eight to the power of six plus two times eight to the
power of seven.
So if we perform the calculations here, we see this octal number is equal to four million five hundred
and fifty nine thousand one hundred fifty nine in base ten.
And that was it for my lesson today.