Skip to main content

Section 3.6 Bytes

One bit of information is so little that usually computer memory is organized into groups of eight bits. Each eight-bit group is called a byte. Because it has 8 bits, it can store \(2^8\) or 256 different values. This makes it appropriate for storing things like a single character of text - with 256 different values we can assign a different 8-bit pattern to each letter, digit, punctuation mark, etc…
When more than eight bits are required for some data, several bytes are used. For example, typically:
  • An integer is represented with a group of 4 bytes (32 bits)
  • A decimal number is represented with a group of 8 bytes (64 bits)
  • A color is repented by a group of 3 bytes (24 bits)
When we are talking about much larger chunks of information, like the information that makes up an entire image or music file, we describe it in terms of Kibibytes, Mebibytes, Gibibytes or even larger quantities. These are all names for different powers of 2:
Table 3.6.1.
Name Number of Bytes Power of 2
Byte 1 \(2^0\)
Kibibyes (KiB) 1024 \(2^{10}\)
Mebibytes (MiB) 1,048,576 \(2^{20}\)
Gibibytes (GiB) 1,073,741,824 \(2^{30}\)
Tebibyte (TiB) 1,099,511,627,776 \(2^{40}\)

Subsection 3.6.1 Powers of 2 vs 10

In the metric system, Kilo, Mega, Giga, etc… refer to different powers of 10. So a Kilobyte, or KB, is \(10^{3}\) bytes. Using that system gives us the following units:
Table 3.6.2.
Name Number of Bytes Power of 10
Byte 1 \(10^{0}\)
Kilobytes (KB) 1000 \(10^{3}\)
Megabytes (MB) 1,000,000 \(10^{6}\)
Gigabytes (GB) 1,000,000,000 \(10^{9}\)
Terabyte (TB) 1,000,000,000,000 \(10^{12}\)
Unfortunately, this distinction between units like KB and KiB is a relatively recent one and is not used consistently. If someone specifies one of the KiB, MiB, etc… values, you can be sure that they mean a power of 2. However, when someone specifies a value without the little i, like KB or MB they may be specifying a power of 2 or 10. “256 MB” can either mean \(256 \times 10^{6}\) or \(256 \times 2^{20}\) bytes. The same source may even use the MB, GB, etc… notation to mean both base 10 and base 2 when describing different measurements. For example, if you buy a computer advertised with “16 GB” of main memory (RAM) and a “500 GB” hard drive, the 16 GB means \(16 \times 2^{30}\) while the 500 GB means \(500 \times 10^{9}\text{!}\)
Fortunately, the values of the base 2 and base 10 systems are close enough that a value like “32 GB” gives you a good idea of how big the value is even if you aren’t sure how to interpret the GB. But if you desire an exact value, you need to figure out whether you should be using \(10^{9}\) or \(2^{30}\) for each GB.

Note 3.6.3.

Traditionally, people describe processor speeds, network speeds, and hard drive space using the power of 10’s system. They describe main memory (RAM) and the size of files and data using the power of 2’s system. This gets a bit confusing when you are calculating something like how long it will take to send a “200 MB” file over a “100 MB/s” network connection - the two MB’s are different units!

Checkpoint 3.6.4.

How many bits are in 3 bytes?

Checkpoint 3.6.5.

How many bytes are in 4KiB?
You have attempted of activities on this page.