Data & Files

Understanding File Sizes: Bits, Bytes, and Beyond

A complete guide to digital storage units from bits to terabytes, including the confusing differences between MB and MiB.

HandyUtils December 27, 2025 6 min read

Why does your "500 GB" hard drive only show 465 GB in your operating system? Why is a "kilobyte" sometimes 1,000 bytes and sometimes 1,024? The world of digital storage units can be surprisingly confusing.

The Building Blocks: Bits and Bytes

Bit (b)

The smallest unit of digital information—a single binary digit:

  • Can be 0 or 1
  • Represents one "decision" or "switch"
  • Network speeds are typically measured in bits

Byte (B)

A group of 8 bits:

  • The fundamental unit for measuring file sizes
  • Can represent 256 different values (2⁸)
  • One byte = one character in ASCII text
1 byte = 8 bits

Example byte: 01000001 = 65 = 'A' in ASCII

The Two Systems: Decimal vs Binary

Here's where confusion begins. There are two different systems for measuring larger units:

Decimal (SI) System

Uses powers of 10 (what manufacturers use):

Unit Abbreviation Bytes Powers of 10
Kilobyte kB 1,000 10³
Megabyte MB 1,000,000 10⁶
Gigabyte GB 1,000,000,000 10⁹
Terabyte TB 1,000,000,000,000 10¹²

Binary (IEC) System

Uses powers of 2 (what computers actually use):

Unit Abbreviation Bytes Powers of 2
Kibibyte KiB 1,024 2¹⁰
Mebibyte MiB 1,048,576 2²⁰
Gibibyte GiB 1,073,741,824 2³⁰
Tebibyte TiB 1,099,511,627,776 2⁴⁰

Why Two Systems?

Computers work in binary (powers of 2), so 1,024 is a natural boundary. But marketing prefers round decimal numbers.

The difference seems small at first:

  • 1 KB vs 1 KiB: 2.4% difference
  • 1 MB vs 1 MiB: 4.9% difference
  • 1 GB vs 1 GiB: 7.4% difference
  • 1 TB vs 1 TiB: 10% difference

The "Missing" Hard Drive Space

This is why your 500 GB drive shows ~465 GB:

Manufacturer (decimal):
500 GB = 500,000,000,000 bytes

Operating system (binary):
500,000,000,000 ÷ 1,073,741,824 = 465.66 GiB

"Missing": 500 - 465.66 = 34.34 GB (≈ 7%)

The bytes are all there—it's just different unit systems!

Common Size References

File Sizes

Content Typical Size
Single character 1 byte
Short text message 100-200 bytes
Small JPEG image 50-100 KB
High-res photo 2-5 MB
MP3 song (3 min) 3-5 MB
HD movie (1080p) 4-8 GB
4K movie 20-50 GB
Operating system 10-30 GB

Storage Capacities

Device Typical Size
Floppy disk (old) 1.44 MB
CD 700 MB
DVD 4.7-8.5 GB
Blu-ray 25-50 GB
USB drives 8 GB - 1 TB
SD cards 32 GB - 1 TB
SSDs 256 GB - 8 TB
Hard drives 1-20 TB

Bits vs Bytes: Network Speeds

Internet speeds are almost always measured in bits, not bytes:

100 Mbps internet ≠ 100 MB/s downloads

100 Mbps (megabits) = 12.5 MB/s (megabytes)

Divide by 8 to convert: bits ÷ 8 = bytes

Common internet speeds:

Advertised Actual Max Download
10 Mbps 1.25 MB/s
100 Mbps 12.5 MB/s
1 Gbps 125 MB/s
10 Gbps 1.25 GB/s

Why bits for networks? Historical reasons—telecommunications measured in bits per second long before bytes became standard for storage.

Calculating File Sizes

Text Files

Plain text: roughly 1 byte per character (ASCII/UTF-8 for English)

"Hello, World!" = 13 characters = 13 bytes

1,000 word essay ≈ 5,000-6,000 bytes ≈ 5-6 KB

Images

Uncompressed image formula:

Size = Width × Height × Color Depth

Example: 1920×1080 image, 24-bit color
= 1920 × 1080 × 3 bytes
= 6,220,800 bytes
≈ 5.93 MB uncompressed

Compressed (JPEG): 200 KB - 1 MB

Audio

Uncompressed audio (CD quality):

Sample rate × Bit depth × Channels × Duration

44,100 Hz × 16 bits × 2 channels × 180 seconds
= 44,100 × 2 × 2 × 180 bytes
= 31,752,000 bytes ≈ 30.3 MB for 3 minutes

MP3 compressed: 3-5 MB for same duration

Video

Video combines many frames plus audio:

Uncompressed 1080p at 30fps:
1920 × 1080 × 3 bytes × 30 fps
= 186,624,000 bytes/second
≈ 178 MB/second
≈ 10.7 GB/minute

H.264 compressed: ~100-300 MB/minute

The Full Scale

From smallest to largest:

Unit Abbreviation Bytes Example
Bit b 1/8 Single binary digit
Byte B 1 One ASCII character
Kilobyte KB 10³ Short email
Kibibyte KiB 2¹⁰ ~
Megabyte MB 10⁶ MP3 song
Mebibyte MiB 2²⁰ ~
Gigabyte GB 10⁹ HD movie
Gibibyte GiB 2³⁰ ~
Terabyte TB 10¹² Large HDD
Tebibyte TiB 2⁴⁰ ~
Petabyte PB 10¹⁵ Data centers
Pebibyte PiB 2⁵⁰ ~
Exabyte EB 10¹⁸ Global internet traffic
Exbibyte EiB 2⁶⁰ ~
Zettabyte ZB 10²¹ World's data
Yottabyte YB 10²⁴ Theoretical

Programming with File Sizes

JavaScript

function formatFileSize(bytes) {
    if (bytes === 0) return '0 Bytes';
    
    const k = 1024; // Use 1000 for decimal
    const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
    const i = Math.floor(Math.log(bytes) / Math.log(k));
    
    return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
}

formatFileSize(1234567890); // "1.15 GB"

Python

def format_file_size(bytes_size):
    for unit in ['B', 'KB', 'MB', 'GB', 'TB']:
        if abs(bytes_size) < 1024.0:
            return f"{bytes_size:.2f} {unit}"
        bytes_size /= 1024.0
    return f"{bytes_size:.2f} PB"

format_file_size(1234567890)  # "1.15 GB"

C#

public static string FormatFileSize(long bytes)
{
    string[] sizes = { "B", "KB", "MB", "GB", "TB" };
    int order = 0;
    double len = bytes;
    while (len >= 1024 && order < sizes.Length - 1)
    {
        order++;
        len /= 1024;
    }
    return $"{len:0.##} {sizes[order]}";
}

Quick Reference: Common Conversions

1 KB = 1,000 bytes
1 MB = 1,000 KB = 1,000,000 bytes
1 GB = 1,000 MB = 1,000,000,000 bytes
1 TB = 1,000 GB = 1,000,000,000,000 bytes

Binary (more accurate for computing):
1 KiB = 1,024 bytes
1 MiB = 1,024 KiB = 1,048,576 bytes
1 GiB = 1,024 MiB = 1,073,741,824 bytes
1 TiB = 1,024 GiB = 1,099,511,627,776 bytes

Network speeds to file transfer:
Mbps ÷ 8 = MB/s (approximately)

Summary

Key takeaways:

  1. 8 bits = 1 byte (always)
  2. Decimal vs Binary: Marketing uses 1000s, computers use 1024s
  3. Network speeds are in bits, file sizes are in bytes
  4. Your drive isn't lying: Different unit systems explain "missing" space
  5. KiB/MiB/GiB are the technically correct binary terms

Understanding these units helps you accurately estimate storage needs, understand network speeds, and know why your devices don't match advertised capacities.

Need to convert between units? Try our File Size Converter!

Related Topics
bits bytes kilobyte megabyte gigabyte storage file size binary data units
Share this article

Continue Reading

Number Systems
Binary Numbers Demystified: How Computers Actually Think

An accessible explanation of binary: why computers use 1s and 0s, how to read binary, and understanding bits and bytes.

Data & Files
CSV Files: The Simple Data Format Everyone Uses

Understanding CSV files, their structure, common pitfalls, and best practices for creating and parsing comma-separated values.

Converters
Metric vs Imperial: A Developer's Quick Reference

A practical guide to metric and imperial unit conversions, with formulas and code examples for common measurements.