# Kilobytes Megabytes Gigabytes Terabytes

The size of information in the computer is measured in kilobytes, megabytes, gigabytes, and terabytes. In this section, we'll look at common sizes you would see in real life, and work some arithmetic. Every person today should be able to think through problems with KB, MB and GB.

## Kilobyte or KB

• Kilobyte KB - about 1 thousand bytes
• As we know, 1 byte is one typed character
- see below for why the phrase "about 1 thousand" is required here
• A small email text is about 2 KB
• A 5 page paper might be 100 KB
• Text is compact, requiring few bytes compared to images or sound or video
• Math: if you have N bytes, that's N/1000 KB
• e.g. 23,000 bytes is about 23 KB

One kilobyte (KB) is a collection of about 1000 bytes. A page of ordinary roman alphabetic text takes about 2 kilobytes to store (about one byte per letter). A typical short email would also take up just 1 or 2 kilobytes. Text is one of the most naturally compact types of data at about one byte required to store each letter. In non-roman alphabets, such as Mandarin, the storage takes up 2 or 4 bytes per "letter" which is still pretty compact compared to audio and images.

## Megabyte or MB

• Megabyte (MB) - about 1 million bytes
• aka about 1000 KB
• MP3 audio is about 1 megabyte per minute
• A high quality digital picture is about 2-5 megabytes
• Math: if you have N KB, that's N/1000 MB
• e.g. 45,400 KB is 45.4 MB

One megabyte is about 1 million bytes (or about 1000 kilobytes). An MP3 audio file of a few minutes or a 10 million pixel image from a digital camera would typically take up few megabytes. The rule of thumb for MP3 audio is that 1 minute of audio takes up about 1 megabyte. Audio and image and video data typically stored in "compressed" form, MP3 being an example. We'll talk about how compression works later. A data CD disk stores about 700 MB. The audio on a CD is not compressed, which is why it takes so much more space than the MP3. The series of bits are represented as spiral path of tiny pits in the silver material in the disk. Imagine that each pit is interpreted as a 0, and the lack of a pit is a 1 as the spiral sequence is read. Fun fact: the whole spiral on a CD is over 5km long.

## Math - You Try It

• 2,000,000 bytes is about how many MB?
• 23,000 KB is about how many MB?
• 500 KB is about how many MB?

## Gigabyte or GB

• Gigabyte GB = about a billion bytes
• aka about 1000 MB
• GB is a common unit for modern hardware
• e.g. 4000 MB = 4 GB
• An ordinary computer might have:
-4 GB or RAM
-256 GB of persistent storage
• A DVD disk has a capacity 4.7GB (single layer)
• -Figure 2 GB per hour of video (varies greatly)
• A flash drive might hold 32 GB
• A small hard drive might hold 750 GB
• Math: if you have N MB, that's N/1000 GB

One gigabyte (GB) is about 1 billion bytes, or 1 thousand megabytes. A computer might have 4 GB of RAM. A flash memory card used in a camera might store 16 GB. A DVD movie is roughly 4-8 GB.

• Math - You Try It
• How many GB is 4,000,000,000 bytes?
• Say you have many 5 MB JPEG images. How many fit on a 16 GB flash drive?

## Terabyte or TB

One terabyte (TB) is about 1000 gigabytes, or roughly 1 trillion bytes. You can buy 4 TB hard drives today, so we are beginning the time when this term comes in to common use. Gigabyte used to be an exotic term too, until Moore's law made it common.

## Gigahertz - Speed, not Bytes

One gigahertz is 1 billion cycles per second (a megahertz is a million cycles per second). Gigahertz is a measure of speed, very roughly the rate that at a CPU can do its simplest operation per second. Gigahertz does not precisely tell you how quickly a CPU gets work done, but it is roughly correlated. Higher gigahertz CPUs also tend to be more expensive to produce and they use more power (and as a result give off more heat) .. a challenge for putting fast CPUs in small devices like phones. The ARM company is famous for producing chips that are very productive with minimal power and heat. Almost all cell phones currently use ARM CPUs.

## Kilobyte / Megabyte / Gigabyte Word Problems

You should be comfortable doing simple arithmetic to figure MB / GB sizes, just as you should be able to do basic computations with second, miles, kilos and so forth.

Basic plan: before adding measures X and Y, convert them to be in the same units.

Word ProblemsSolution
Alice has 600 MB of data. Bob has 2000 MB of data. Will it all fit on Alice's 4 GB thumb drive?
Alice has 100 small images, each of which is 500 KB. How much space do they take up overall in MB?
Your ghost hunting group is recording the sound inside a haunted Stanford classroom for 20 hours as MP3 audio files. About how much data will that be, expressed in GB?

## Alternate Terminology: Kibibyte Mebibyte Gibibyte Tebibyte

It's convenient within the computer to organize things in groups of powers of 2. For example, 210 is 1024, and so a program might group 1024 items together, as a sort of "round" number of things within the computer. The term "kilobyte" above refers to this group size of 1024 things. However, people also group things by thousands -- 1 thousand or 1 million items.

There's this problem with the word "megabyte" .. does it mean 1024 * 1024 bytes, i.e. 220 which is 1,048,576, or does it mean exactly 1 million, 1000 * 1000. It's just a 5% difference, but marketers tend to prefer the 1 million, interpretation, since it makes their hard drives etc. appear to hold a little bit more. Also, the difference grows larger and larger for the gigabyte and terabyte sizes. In an attempt to fix this, the terms "kibibyte" "mebibyte" "gibibyte" "tebibyte" have been introduced to specifically mean the 1024 based units (see wikipedia kibibyte article). These terms do not seem to have caught on very strongly thus far. If nothing else, remember that terms like "megabyte" have this little wiggle room in them between the 1024 and 1000 based meanings. We will never grade off for this distinction .. "about a million" will be our close-enough interpretation for "megabyte". The "error" at the megabyte level is about 5%. At the terabyte level the error is about 10%.