video

Lesson video

In progress...

Loading...

Hi, I'm Rebecca, your computing teacher for the Data Representations Unit.

For this lesson, you're going to need a pen and paper to answer any of the questions that I give you and to make notes.

And you're also going to need to remove as many distractions as you possibly can so that you can really focus in this lesson.

Once you've done all of that, we can begin.

In this lesson you will explain how numbers are represented using hexadecimal, you'll convert decimal numbers to and from hexadecimal.

And you'll explain why and where hexadecimal notation is used.

Quick quiz to get you started then, so what's binary? Is it Base 10 or Base two? it's Base two, isn't it? And how many digits does decimal have? It has 10.

Now we're going to be looking at hexadecimal in this lesson.

Hexadecimal is a base 16 number system.

How many digits do you think it has? It has 16.

So the digits used for hexadecimal are here.

And you'll notice that you've got some letters there A to F to represent 10 to 15.

Hexadecimal is often used instead of binary, because it is easier to read and interpret.

It uses fewer digits to represent the same value.

That's very important to remember, and compared to binary, it is less likely that a digit will be written down incorrectly.

So there you can see a hex number at the top and a binary number underneath it.

You work out the place value by multiplying by 16, as you move from right to left.

This is just like we did with the other ones, except you're doing time 16, this time.

If you wanted to convert a hexadecimal value into decimal, then you could follow the same rules as we had with binary.

So you do A is 10, so you'll do 10 times 16, and one is one, so you just do one times one, and then you get the answers, you add them together.

And A one in decimal is 106, sorry, A one in hexadecimal is 161 in decimal.

Again, converting from decimal to hexadecimal is a little like when we converted from decimal to binary.

However, the maths can be a little more challenging.

There's a little warning for you.

Let's take the decimal value 180 and convert it to hexadecimal.

Remember, we are working with 16 digits now and not just two.

So there are extra steps to take, let's take a look.

So firstly, 256 will not go into 180, so we know that we don't need that column, but 16 does go into 180, but we don't just simply put a one there because that wouldn't work, remember this isn't binary.

We need to know how many times 16 goes into 180.

So you've got to do some division there.

So does 16 go into one? No.

Does 16 go into 18? Yes, it goes in once.

And then with two remaining.

So two gets moved over into the right hand column.

Does 16 go into 20? Yes it does, and it goes in once, but with four remaining.

So 16 goes into 180, 11 times with four remaining.

So 11 in hexadecimal, isn't 11 is a B, remember 10 is A, 11 is B.

So we add a B to the 16 column.

And then we're just left with four, which is just the same looking value of a four in our decimal system is a four in hexadecimal as well, so we can just put a four in there.

So 180 in decimal is B4 in hexadecimal.

Note that calculators are not allowed in your examination.

So you would need to do all of this in your head.

So if you find division quite tricky, I do have another way around it, if you found that tricky.

There must be a better way, there is a better way.

This is my way, 'cause I do love math, but I'm slow at math, it takes me much longer to work, things like that out.

And I don't want to get confused with remembering how to do division.

So I'm going to do it this other way instead, like this.

So first of all, in order to do the better way or the other way, you need to draw these two tables and I'll explain why after you've drawn them.

So pause the video while you draw these two tables.

So if you look at these two tables, the first one is just there to help you remember what all those letters mean.

So A 10, all the way up to F which is 15, 'cause in any situation, sometimes it's hard to remember those, but certainly in an exam, you want to make sure that you get those letters right, 'cause you could just make a very slight mistake with the numbers and lose a mark just because you haven't remembered the B's 11 or D is 13.

So remembering that table is a really good way to help you remember this.

So then you've got the other table.

Now, each pole of that other table, you can see it's been broken down into four parts, but each of those sections, would take up one byte of storage.

And this only works with values up to one byte.

So if you wanted to do a higher value, so if it was higher than, if it was like A, A, A in hex, you wouldn't be able to use this table.

You could add extra bits to the table and do it, but really only works with only eight bits.

Now in the exam, again, you're only going to get eight bits or two nibbles or a hex with two values on it in your exam.

So this is perfect for GCSE.

So it's obviously , when you go into high level, you'll probably be working with larger numbers than this.

So each of the sections would take one byte of storage and this table, as it is only works with one byte.

So first of all, you've got hex, so two hexadecimal values use one byte of storage and then you've got their two nibbles and a nibble is half a byte and it's equivalent to one byte of storage.

So two nibbles is the same as one byte of storage.

Then you've got eight bits and there are eight bits in a byte also bits and bytes and nibbles, I think somebody who was eating an apple when they came up with all of these things.

So you've got their eight bits in a byte, and again, that's a byte.

And then this final one is the decimal number and a decimal value that we will be using.

And that will come up in exams as well, will always be less than 256.

So this means that they take up one byte of storage.

So you can't put.

This won't work if you put 512 in that decimal column, okay? So you've drawn the two tables, now you need to know how this actually works, so that it's, you don't have to do that division in your exam.

So we're going to start by doing A two in hex to decimals.

So the value A two, which is 16 into decimal, and this is how you would do it.

So you start off by putting A2 in the hex column, 'cause that's your hex number and you want to convert it to decimal, which is all the way over there in that right hand column.

So you start off with A two there, then you separate it into two nibbles.

So A in that first column there we convert in A, A is 10 and 10 in binary is one, zero, one, zero.

And you can just double check that with the headings that are on there.

So eight plus two is 10.

So of course, one, zero, one, zero is 10 in binary, which is A in hex, so that's what we've done there.

Then we take the two and we put it into the next nibble.

So two is just zero, zero, two, zero.

And we can double, sorry, not two, zero, zero, one, zero.

And if you look at the number of one, you can see that the one that's on is two, so that's the value two.

So two is two in decimal, it's two in hex, but zero, zero, one, zero in binary.

We then transfer those two nibbles over into the eight bits section.

So do that first bit first one, zero, one, zero.

And then you put the second half in zero, zero, one, zero.

So we've just put exactly the same.

So this is showing you that, hex with two values in it is eight bit, yeah, which is a byte, which is the same as two nibbles, which is the same as one byte or eight bits.

So we've put that and then we just need to do a normal addition that we've got to work out the decimal number.

So you look at those headings, see which ones have got a one underneath them, and then you add them all together and it makes 162.

So, to me I find that much, much easier once you've learned this table and how to do it and how it works, you can do that conversion any way round you want.

You can do from hexadecimal, decimal to hex, decimal to binary, binary to do nibbles, you can use it for all sorts of situations.

That's why it's such a cool tool to use.

So let's try another one.

So we're going to convert 180 in decimal this time, we know it's in decimal because it's got the base 10 on next to the number two hexadecimal.

So this time we're starting with a decimal number.

So we put that in the decimal column and then we do the other way.

So we start off by thinking well, does 128 fit into 80? Yes, it does, so we put a one there, which is.

This is just the normal decimal to binary conversions that you've been doing already in these lessons.

So this should be quite familiar with you already.

And then you take away the 128, you're left with 52, does 64 fit into 52? No, it doesn't, does 32? Yes it does.

And then I've got to take it away and I'm left with 20.

Does 16 fit into 20, yes, it does.

So I put a one and then I'm left with four, so I know that I've just got to put zero, and then one, zero, zero, there.

Hopefully I'm doing that too fast because I think you already know how to do that by now.

If you want to slow it down, then you can do and just go back.

So now I've done bit, I literally just do exactly the same thing and copy it all over into those two nibbles.

So copy the left hand side into the left nibbles and the right hand side into the right nibbles.

And then I just convert each nibbles into its hex value, so eight plus two plus one is 11, eight, nine, 10, 11.

Yeah, and then 11 in hex is B, so I put a B there.

Then you've got the second nibble, which is zero, one, zero, zero, which is four and four is just four in hex, so we put a four there as well.

You with me? If you're not, you can always rewind and look at it again.

So now we're done, we can try another one.

So now, if we look at this value, it's one more and more and more, more, more, more and it's in binary and we know that because he's got a base of two at the bottom of it, so we convert in binary to decimal.

So we just add that binary number into the eight bit binary section.

Then we transfer it over.

So the first half into the first nibble, the second half into the second nibble, then we do our conversion.

So eight plus four plus two plus one is 15.

We find 15 on our other table, which makes it an F so point F in there and the other one, exactly the same, isn't it? We know there's going to be an F, so we have two Fs like that.

So what I want you to do then is use those two tables to do all of those conversions yourself.

And hopefully you'll start to see it's much easier than doing that division.

That I'm dividing that 16 divided by whatever the value is.

So have a go, pause the video while you try it yourself.

Here's the solutions then, so pause the video while you mark your work.

Now, where might we see hex values? So, first of all, if you've ever looked at HTML code, then you might have , if you've programmed , or if you've just viewed the source for website, you might see some HTML code there and you might have seen something where it's looking at the colour and you might've seen a hashtag and then lots of random letters and numbers.

Well, that's actually a hex value there.

That's been used to select the colour that's going to be used on that website, in this case, it's electric purple.

You can also see these hex values used in MAC addresses.

So that's a MAC address for a Raspberry PI computer there.

So all those strange letters and numbers, they're just hex values that have been used there to simplify it.

So remember, it's the same value as those bits and bytes, those binary numbers, but it's just looks shorter on the screen.

So it's much, much easier to read and interpret.

Memory dumps, you might've seen something like this in the past, on your computer and they're just all hex values are showing memory and picking colours.

So if you've ever picked colours in a package anywhere like a drawing package or a Google slides package, something like that, then you might have noticed that there were hex values there for the colours and if you look, you've got F, F zero, zero, zero, zero F, F, and that is the code, the hex code they're used for that colour, so it's used in quite a lot of situations.

So hopefully now you've got a good idea of what hex is, it's a base 16 and we use it in computing to make it easy to read and interpret, it's a shorter number, but that doesn't mean it's less memory, it's still going to take up the same amount of memory is just shorter to look at.

And hopefully you've had a good practise at using those.

And if you really want to do the division way, do the division way, it's just, I prefer to do it using those two tables, 'cause I find it much easier and it's much simpler maths as well that you need to do.

And the last thing you want to be doing is stressing about division and things like that, and getting your numbers wrong in an exam, you want to be as calm as you possibly can.

So hopefully you can try those, that method I have to on some more numbers.

And you can always find websites that convert those values for you, so that you can check if you are right or not.

If you'd like to please ask your parent or care to share your work on Instagram, Facebook, or Twitter, tagging @OakNational and hashtag LearnwithOak, 'cause I've lived to see maybe you score for you that you got there for that quiz at the end to see how you got on.

And I look forward to seeing you for lesson five.