Transcript
  • Computer Science

Binary Orders of Magnitude (KB, MB, GB)

From the class:  The Binary Number System

Before we go on to two other number systems that we're going to use often in computing, I wanted to take a break and talk about the orders of magnitude of bits. These are terms that you're going to use often, even if you're not in computer science, just by buying a computer, for example, and seeing how much memory it has or how much disk space it has. So let's take a few minutes to review the different sizes that we talk about in computing.

You've already seen that eight bits or eight of those slots that we can either put a 1 or a 0 in, that's equal to one byte. And normally in computing, we just talk about bytes. And that's sometimes denoted with a capital B. So if you see something like 5B, that usually means five bytes.

Now, kilo normally means to multiply something by 1,000. So in base 10, when we talk about kilo, it's normally 1,000. But in computing, we use a different number for kilo. And it's actually 2 to the 10th power, which is equal to 1,024. So this is going to be a kilobyte or just kb for short. And oftentimes it's just written as k. So if you see something like 5K, what that means is 5 times 1,024, and that's how many bytes you're going to have.

All right, let's clean this up and write this out in table form. So we've just said that one kilobyte is equal to 1,024. And I'm just going to say to the first power here, because we're about to increase this number. But it's equal to 1,024 bytes. And if you want to know how many bits that is, you can multiply that by 8, since one byte is equal to eight bits. And that gives us 8,192 bits. So that's those little slots that could be 1 or 0.

Now if we go to megabytes, so if we say one megabyte, which is a capital M capital B. But oftentimes you just see it as the M. That's going to be equal to 1,024 squared bytes. And that is going to equal 1 million, pull out your calculator and just type it in, 48,576 bytes. And you multiply that by 8 to get the number of bits. And so that's an awful lot of slots.

Now going up to the next order of magnitude, we're going to look at gigabytes. So one gigabyte, with a capital G, is equal to 1,024 to the third power. That's how many bytes it's equal to. And if you multiply that out with a calculator, that gives you, let's see, 1,073,741,824 bytes. That's an awful lot of bytes.

And we can just keep going all the way up. Normally we don't go too much further past gigabytes, because that happens to be the sort of max that we're at now. But you could go up to a peta, petabytes. And we would just keep applying the same logic. So this is going to be to the fourth. And then we could even go up to one terabytes, if you have a big storage system, for example. And that's going to be 1,024 to the fifth.

So if you want to know how many kilobytes something is and you have bytes, so you can divide it by 1,024 and you can go between these different numbers by dividing and multiplying.

To give you an example of that, let's say somebody comes along and they say, you've got a computer program that prints out but you've got 536,870,912 bytes. And you want to know how many gigabytes that's going to be. Well, what we can do is just take this entire sum and divide it by the number of bytes in a gigabyte. And so that's going to be 1,024 to the third power. And that's how many bytes are in one gigabyte. And if you type that into your calculator and do the division, you will find that the answer is 0.5. So that's 0.5 gigabytes and that's what this number up here represents in bytes.

Now let's see, we've got 0.5 gigabytes, but we want to figure out how many megabytes that is. Well, I find it useful to just keep a table of these things until you get used to it. So we could say one kilobyte is equal to 1,024. One megabyte is equal to 1,024 squared. And one gigabyte is equal to 1,024 to the third power.

So now if we want to go from gigabytes to megabytes, we need to go down by a factor of 1,024. So what we can do is just take 0.5 and multiply it. So 0.5 times 1,024. And that's going to give us, let's see, 1,024 times half of that is going to be 512. So that's going to be 512 megabytes is equal to 1/2 a gigabyte.

Now, if that math was a little bit confusing to you, let me do it out in long form. You can use the old ratio trick that we learned in math, where we could say that if one gigabyte is equal to how many megabytes, well it's just one more factor of 1,024. So instead of 1,024 squared, it's 1,024 cubed. So we're going to say that one gigabyte is equal to 1,024 megabytes.

And then we set that equal to the thing that we're trying to figure out. So if we have 0.5 gigabytes, how many megabytes is that? And then we could just solve this equation. And so x is going to equal 0.5 times 1,024. And that gives us our answer. That's how many megabytes are in 0.5 gigabytes.

Now, this math seems a little bit tricky or your mind isn't quite wrapping around going back and forth between these different units of measure. Don't worry, it's not intuitive. I think that if you do enough practice, do enough of these and you practice it enough, eventually your brain just kind of gets it and you get pretty quick at it. So try few examples and go back and forth between the different units and see if you can start to develop just an intuition for the answers.