DEV Community

Shankar L
Shankar L

Posted on

Bits, Bytes, KB, MB, GB, TB Explained Simply

Why should you care?

Have you ever wondered why:

  • A photo is 3 MB
  • A movie is 2 GB
  • Your laptop has 16 GB RAM
  • An SSD is 512 GB
  • Internet speed is advertised as 100 Mbps instead of 100 MBps

These units appear everywhere in computing, yet they're often misunderstood.

Understanding the difference between bits, bytes, and larger storage units will help you understand how computers store data, measure memory, and transfer information over networks.


The Problem

Suppose someone tells you:

This file is 8000 bits.
Enter fullscreen mode Exit fullscreen mode

Another person says:

This file is 1000 bytes.
Enter fullscreen mode Exit fullscreen mode

Are they different?

No.

They represent the same amount of data.

Many beginners confuse bits and bytes, leading to mistakes when comparing storage sizes and internet speeds.

Let's fix that once and for all.


The Concept

Everything inside a computer is stored as binary.

The smallest unit of information is a bit.

Bit

0
or
1
Enter fullscreen mode Exit fullscreen mode

A single bit can represent only one of two values.

To store useful information, computers group bits together.

The most common group is called a byte.

1 Byte = 8 Bits
Enter fullscreen mode Exit fullscreen mode

A byte can represent:

2⁸ = 256
Enter fullscreen mode Exit fullscreen mode

different values.

This is enough to store one ASCII character.

Example:

'A' → 01000001
Enter fullscreen mode Exit fullscreen mode

Simple Explanation

Think of bits as individual LEGO bricks.

One brick alone cannot build much.

When you combine eight bricks, you can build something useful.

Similarly:

1 Bit

↓

8 Bits

↓

1 Byte
Enter fullscreen mode Exit fullscreen mode

Larger groups of bytes are used to measure storage.

Unit Size
1 Byte (B) 8 Bits
1 Kilobyte (KB) 1024 Bytes
1 Megabyte (MB) 1024 KB
1 Gigabyte (GB) 1024 MB
1 Terabyte (TB) 1024 GB

Every step is multiplied by 1024, not 1000, because computers use binary.


Real-world Analogy

Imagine you're transporting books.

  • One page is like a bit.
  • One book is like a byte.
  • A bookshelf is like a kilobyte.
  • A library is like a gigabyte.

As the amount of information grows, we use larger units to avoid writing huge numbers.

Instead of saying:

1,073,741,824 Bytes
Enter fullscreen mode Exit fullscreen mode

we simply say:

1 GB
Enter fullscreen mode Exit fullscreen mode

Much easier to read.


Code Example

Java provides constants that make it easy to calculate storage sizes.

public class Main {
    public static void main(String[] args) {

        long KB = 1024;
        long MB = KB * 1024;
        long GB = MB * 1024;
        long TB = GB * 1024;

        System.out.println("1 KB = " + KB + " Bytes");
        System.out.println("1 MB = " + MB + " Bytes");
        System.out.println("1 GB = " + GB + " Bytes");
        System.out.println("1 TB = " + TB + " Bytes");
    }
}
Enter fullscreen mode Exit fullscreen mode

Output:

1 KB = 1024 Bytes
1 MB = 1048576 Bytes
1 GB = 1073741824 Bytes
1 TB = 1099511627776 Bytes
Enter fullscreen mode Exit fullscreen mode

Common Mistakes

Mistake 1

Confusing bits with bytes.

Remember:

b = bit
B = Byte
Enter fullscreen mode Exit fullscreen mode

Example:

100 Mbps
Enter fullscreen mode Exit fullscreen mode

is not the same as

100 MB/s
Enter fullscreen mode Exit fullscreen mode

Mistake 2

Thinking internet speed and file size use the same units.

Storage devices usually use bytes.

Network speeds usually use bits.

Example:

Download Speed

100 Mbps

↓

Actual Maximum Speed

About 12.5 MB/s
Enter fullscreen mode Exit fullscreen mode

Because:

8 bits = 1 byte
Enter fullscreen mode Exit fullscreen mode

Mistake 3

Believing KB always means exactly 1000 bytes.

Traditionally in computing:

1 KB = 1024 Bytes
Enter fullscreen mode Exit fullscreen mode

However, storage manufacturers sometimes use:

1 KB = 1000 Bytes
Enter fullscreen mode Exit fullscreen mode

This is why the available storage on a new hard drive may appear slightly smaller than advertised.


Mistake 4

Thinking one character always uses one byte.

Not always.

ASCII uses one byte.

Unicode encodings like UTF-8 may use one to four bytes depending on the character.


Advanced Notes

Binary Prefixes

To avoid confusion, international standards introduced binary prefixes.

Decimal Prefix Binary Prefix
KB = 1000 Bytes KiB = 1024 Bytes
MB = 1000 KB MiB = 1024 KiB
GB = 1000 MB GiB = 1024 MiB
TB = 1000 GB TiB = 1024 GiB

Operating systems and manufacturers do not always display these prefixes consistently.


RAM

When you buy:

16 GB RAM
Enter fullscreen mode Exit fullscreen mode

it means your computer can temporarily store roughly sixteen billion bytes of data while programs are running.

RAM is temporary storage.

Its contents disappear when the computer is turned off.


Storage Devices

Typical storage sizes:

Device Capacity
USB Drive 16 GB to 256 GB
SSD 256 GB to 4 TB
HDD 1 TB to 20 TB

These values represent how much data can be stored.


Why 1024?

Since computers work in binary:

2¹⁰ = 1024
Enter fullscreen mode Exit fullscreen mode

This is the closest binary value to 1000, making it a natural choice for measuring memory.


Summary

Everything stored inside a computer is ultimately made of bits.

Those bits are grouped into bytes, and bytes are grouped into larger storage units.

1 Bit

↓

8 Bits

↓

1 Byte

↓

1024 Bytes

↓

1 KB

↓

1024 KB

↓

1 MB

↓

1024 MB

↓

1 GB

↓

1024 GB

↓

1 TB
Enter fullscreen mode Exit fullscreen mode

Remember these key facts:

  • A bit is the smallest unit of data.
  • One byte contains eight bits.
  • Storage is usually measured in bytes.
  • Internet speed is usually measured in bits.
  • Larger units help us represent huge amounts of data more conveniently.

Understanding these units makes it much easier to compare storage devices, estimate download times, and understand how computers manage information.


Top comments (0)