How bits and bytes work in computer memory

8

If you have owned a computer for longer than a coffee break, you have seen the terms bits and bytes thrown around. They are the standard units for measuring RAM, hard disk capacity, and file sizes in any modern file viewer.

You might hear a sales pitch claiming a machine has a 32-bit Pentium processor with 64 megabytes of RAM and 2.1 gigabytes of hard disk space. These specs appear in tech guides and tutorials constantly. Understanding what these terms actually mean helps you stop guessing and start knowing.

Decimal Numbers

To grasp a bit, compare it to something familiar: digits.

A digit is a single slot for a value between 0 and 9. We combine these to make larger numbers. Take 6,357. It has four digits. The 7 sits in the “1s place.” The 5 is in the 10s place. The 3 is in the 100s place. The 6 holds the 1,000s place.

You can write that out explicitly:

(6 * 1000) + (3 * 100) + (5 * 10) + (7 * 1) = 6000 + 300 + 50 + 7 = 6357

Or use powers of 10. Using the caret symbol (^) for “to the power of,” it looks like this:

(6 * 10^3) + (3 * 10^2) + (5 * 10^1) + (10^0) = 6000 + 300 + 50 + 7 = 6357

Each digit is a placeholder for the next higher power of 10. The first digit starts at 10^0.

This feels normal because we use a base-10 system daily. It likely exists because humans have ten fingers. If we evolved with eight fingers, we would probably use a base-8 system. You can use any base you want. Different bases make sense in different contexts.

Computers use the base-2 number system. It is also known as the binary number system.

The Base-2 System and the 8-bit Byte

Computers use base-2 because it is cheap. You could build a base-10 computer. It would just be fiendishly expensive. Base-2 hardware is relatively affordable.

So computers use binary numbers. They use binary digits instead of decimal digits. The word bit shortens “Binary digIT.”

Decimal digits have 10 values: 0 through 9. Bits only have two values: 0 and 1. A binary number is just a string of 0s and 1s, like 1011.

To find the value, use base-2 powers instead of base-10.

(1 * 2^3) + (0 * 2^2) + (1 * 2^1) + (1 * 2^0) = 8 + 0 + 2 + 1 = 11

Each bit represents increasing powers of 2. Counting in binary is straightforward. Here is how decimal and binary compare from 0 to 20:

  • 0 = 0
  • 1 = 1
  • 2 = 10
  • 3 = 11
  • 4 = 100
  • 5 = 101
  • 6 = 110
  • 7 = 111
  • 8 = 1000
  • 9 = 1001
  • 10 = 1010
  • 11 = 1011
  • 12 = 1100
  • 13 = 1101
  • 14 = 1110
  • 15 = 1111
  • 16 = 10000
  • 17 = 10001
  • 18 = 10010
  • 19 = 10011
  • 20 = 10100

Notice the carry-over. At number 2, binary carries for the first time. If a bit is 1 and you add 1, it becomes 0 and the next bit becomes 1. Going from 15 to 16 rolls over through four bits, turning 1111 into 10000.

Bits rarely travel alone. They are bundled into 8-bit collections. These bundles are called bytes.

Why eight bits in a byte? It is like asking why there are 12 eggs in a dozen. People settled on 8 bits through trial and error over the last 50 years.

With 8 bits, you can represent 256 values. They range from 0 to 255.

  • 0 = 00000000
  • 1 = 00000001
  • 2 = 00000010
  • 254 = 11111110
  • 255 = 11111111

In How CDs Work, you learn that a CD uses 2 bytes per sample. That is 16 bits. Each sample can range from 0 to 65,535.

  • 0 = 0000000000000000
  • 1 = 0000000000000001
  • 2 = 0000000000000010
  • 65534 = 1111111111111110
  • 65535 = 1111111111111111

Next, we will look at one way bytes are used.

How ASCII Encoding and Binary Math Power Your Data

Text isn’t magic. It’s just numbers wearing a costume.

When you type a sentence, your computer doesn’t see letters. It sees binary values. Specifically, it relies on the standard ASCII character set to turn keystrokes into data. In this system, every binary value from 0 to 127 maps to a specific character. Most systems stretch this to 256 values using a full byte, adding accented letters and symbols for international languages.

But the core 128 codes are where the foundation lies.

Consider Windows 95/98 Notepad. If you type “Four score and seven years ago,” the software allocates exactly one byte of memory per character. This includes the spaces between words. Space is ASCII code 32. Period is 46. ‘A’ is 65.

Try it yourself.

Create a file named getty.txt. Type that sentence. Save it. Open your file explorer. The size is 30 bytes. Why? Because there are 30 characters. Add one word. The file grows by the number of letters in that word. It’s a direct 1:1 ratio.

Open the file as raw data, and the letters vanish. You see numbers.

These are decimal representations of ASCII codes. To be technically precise, the machine only sees binary. 32 becomes 00100000. But the logic holds: each byte holds one character.

The first 32 values (0 through 31) aren’t letters. They’re control codes. Carriage returns. Line feeds. Bell sounds. The actual printable characters start at 32. Punctuation comes next. Then digits. Then uppercase. Then lowercase. You can view the full chart on Unicode.org, but the principle is simple. Text storage is just a list of these integers.

Understanding Byte Prefixes and Binary Math

Once you grasp that data is just bytes, you run into a new problem: scale.

A byte is small. Most files are huge. So we need prefixes.

We use byte prefixes to denote magnitude. Kilo, mega, giga. These aren’t just marketing terms. They are binary multipliers.

  • Kilo (K): $2^{10}$ = 1,024 bytes
  • Mega (M): $2^{20}$ = 1,048,576 bytes
  • Giga (G): $2^{30}$ = 1,073,741,824 bytes
  • Tera (T): $2^{40}$ = ~1.1 trillion bytes
  • Peta (P): $2^{50}$ = ~1.1 quadrillion bytes
  • Exa (E): $2^{60}$ = ~1.1 quintillion bytes
  • Zetta (Z): $2^{70}$
  • Yotta (Y): $2^{80}$

Kilo is roughly a thousand. Mega is a million. Giga is a billion.

When someone claims their hard drive is “2 gigabytes,” they mean $2 \times 2^{30}$ bytes. Exactly 2,147,483,648 bytes.

That sounds abstract until you visualize the data. A standard CD holds about 650 megabytes. Three CDs fill a 2GB drive. A terabyte database is common. Petabyte databases likely exist at major government facilities. The scale grows exponentially.

This brings us to binary math.

It operates like decimal math, with one strict constraint. Each bit can only be 0 or 1.

In decimal, we count 0-9. When we hit 9 and add 1, we carry the 1 to the next column. Binary works identically, but the carry happens faster.

Take decimal addition:

Start right. $2+1=3$. Next column: $5+5=10$. Write 0, carry 1. Next: $4+7+1(carry)=12$. Write 2, carry 1. Final: $0+0+1=1$. Result: 1203.

Now, binary.

Rightmost bit: $0+1=1$. No carry.
Second bit: $1+1=10$. Write 0, carry 1.
Third bit: $0+1+1(carry)=10$. Write 0, carry 1.
Fourth bit: $0+0+1(carry)=1$.

Result is 1001. In decimal, that’s 9. The math is identical. The representation is just base-2 instead of base-10.

The Bottom Line

Bits are binary digits. They are 0 or 1.
Bytes are groups of 8 bits.
Text is just a sequence of bytes mapped to ASCII codes.
Storage size is measured in binary powers of 1,024.

It’s not complicated. It’s just foundational.

For deeper dives into boolean logic and gate implementations, look up how boolean addition works. The rest is just counting in binary.