### The Bits and Bytes of Computer Memory

#### What is a Bit?

A bit is the smallest amount of memory a computer can hold. A bit can literally hold only one of two values: 0 or 1.

Think of this as a bit either being on or off, light or dark, true or false.

While a bit in itself can hold very little data, bits are strung together in larger chunks that can hold more useful information. For example, eight bits make up a byte, which can hold a value from 0-255.

#### What is a Byte?

In computer memory terms, a byte is a collection of eight bits. Unlike a bit that can hold the value of zero or one, a byte of memory can hold a value from 0-255.

Think of the below number as eight individual bits making up a byte, all turned off. The value is 0.

00000000

If we turn on the right-most bit in the byte, the 0th bit (computer scientists love to count starting from the number 0), the value is now one.

00000001

What if we want to add 1 to the value? Remember that a bit can only hold values of 0 or 1. So how is the number 2 represented? We turn on the bit to the left, the 1st bit, like so:

00000010

If the first bit is a 1 and the 0th bit is 0, the total value of all bits is 2. Now what if we want to add 1 to create a byte value of 3? Turn that 1st bit on again.

00000011

What happens if we want to create a value of 4? Remember how the 1st bit represented the number 2? The 2nd bit represents the number 4. Turn it on and turn the other two bits off.

00000100

And so forth. Here is a table:

Bit 7 - Value of 128
Bit 6 - Value of 64
Bit 5 - Value of 32
Bit 4 - Value of 16
Bit 3 - Value of 8
Bit 2 - Value of 4
Bit 1 - Value of 2
Bit 0 - Value of 1

If you know what exponentiation means, think of each bit taking on the value of two to the power of the bit number. 2 to the power of 0 is 1, 2 to the power of 1 is 2, etc.

So to get a byte value of 255, let's turn all of the bits on.

11111111

Several bytes can be strung together to form kilobytes, megabytes, gigabytes, and terabytes.

#### What is a Kilobyte? Megabyte? Gigabyte? Terabyte?

Computers and storage mechanisms (CD-ROMs, hard drives, USB flash drives, DVD-ROMs, etc.) need to hold much larger values than what a byte can hold (0-255). Thus, the terms kilobyte, megabyte, gigabyte, and terabyte were created to represent such large amounts of information.

A kilobyte is 1,024 bytes; however many people think of it as 1,000 bytes.

A megabyte is 1,024 kilobytes; however many people think of it as 1,000 kilobytes.

A gigabyte is 1,024 megabytes; however many people think of it as 1,000 megabytes.

A terabyte is 1,024 gigabytes; however many people think of it as 1,000 gigabytes.

Why the confusion? There are two numbering systems in play. Strictly in "computerese", a base 2 system is in play, so that one kilobyte is 2 to the power of 10 bytes, or 1024 kilobytes. However, many hardware manufacturers, including hard drive manufacturers think of a kilobyte as only 1,000 bytes, or 10 to the power of 3 bytes.

This is the same with megabytes, gigabytes, and terabytes, and that is why when you buy a hard drive with, for example, 400 gigabytes, you may not be getting exactly the amount of room that you think!