Bits and Bytes Formula

A bit is a single binary digit (0 or 1), the smallest unit of digital data.

The Formula

n bits can represent 2n different values

Ask yourself: Is the question how many values some bits can hold, or how much space or speed something needs in bits or bytes?

Quick example

1 bit: 2 values (0 or 1). 1 byte: 256 values (0–255). The letter 'A' = 65 in one byte.

Notation

Bits are abbreviated 'b' (lowercase) and bytes are 'B' (uppercase). Storage uses decimal units, KB (kilobyte = 1000 bytes), MB (106 bytes) and GB (109 bytes), and binary units, KiB (kibibyte = 210 = 1024 bytes), MiB (220 bytes) and GiB (230 bytes). Some operating systems show the binary value but label it KB, MB or GB.

What this formula means

A bit is a single binary digit (0 or 1), the smallest unit of digital data. A byte is a group of 8 bits that can represent 256 different values (0 to 255), enough to encode one text character. All digital storage and communication is measured in bits and bytes.

Bits behave like coin flips in a row: one flip has 2 outcomes, two flips have 4, ten flips have 1,024, because each new flip doubles every list of results so far. A byte is a row of 8 flips, 256 possible rows. The comparison stops at chance: a computer sets each bit on purpose.

Formal view

A bit holds one of two values: {0,1}. A byte is an ordered 8-tuple of bits: (b7,b6,…,b0) where each bi∈{0,1}, representing the value ∑i=07bi⋅2i.

Worked examples

Example 1

easy
How many different values can be represented with 3 bits? List all possible 3-bit binary patterns.
Show solution

Answer

8 different values (0 to 7): 000, 001, 010, 011, 100, 101, 110, 111.

First step

1.
Step 1: Each bit can be 0 or 1. With 3 bits, the number of combinations is 23=8.

Full solution

  1. 2.
    Step 2: The patterns are: 000, 001, 010, 011, 100, 101, 110, 111.
  2. 3.
    Step 3: These represent the values 0 through 7 in decimal. In general, n bits can represent 2n different values.
A bit is the smallest unit of data (0 or 1). The number of possible values doubles with each additional bit: 1 bit = 2 values, 2 bits = 4, 3 bits = 8, and so on.

Example 2

medium
Convert between storage units: (a) How many bytes in 2 kilobytes? (b) A file is 3,145,728 bytes — how many megabytes is that? (c) How many bits in 1 byte?

Example 3

medium
You need a unique code for each of 500 items. How many bits and how many whole bytes are required?

Common mistakes

  • Confusing bits (b) with bytes (B) in speed and storage measurements
  • Forgetting that n bits represent 2n values, not n values
  • Mixing decimal units (KB = 1000 bytes) with binary units (KiB = 1024 bytes), such as expecting a '500 GB' drive to show as 500 GiB rather than about 466 GiB

Common mistakes guide

If this formula keeps breaking in real problems, read the most common errors before you practice again.

Why this formula matters

Bits and bytes let you predict things before they happen: how many photos fit on a phone, how long a download takes, why a color channel stops at 255. The common slip is mixing them up. A 50 Mbps connection moves about 6.25 megabytes a second, not 50, so a 500 MB game takes about 80 seconds to download, not 10.

Frequently asked questions

What is the Bits and Bytes formula?

A bit is a single binary digit (0 or 1), the smallest unit of digital data. A byte is a group of 8 bits that can represent 256 different values (0 to 255), enough to encode one text character. All digital storage and communication is measured in bits and bytes.

How do you use the Bits and Bytes formula?

Use bits and bytes when a question asks how many different values a number of bits can hold, how much storage something needs, or how fast data moves. Watch the units: b is bits, B is bytes, and Mbps is megabits per second. If the question asks the value of one particular 0/1 pattern, that is Binary. If it asks what a pattern stands for (a letter, a pixel color), that is Data Representation.

What do the symbols mean in the Bits and Bytes formula?

Bits are abbreviated 'b' (lowercase) and bytes are 'B' (uppercase). Storage uses decimal units, KB (kilobyte = 1000 bytes), MB (106 bytes) and GB (109 bytes), and binary units, KiB (kibibyte = 210 = 1024 bytes), MiB (220 bytes) and GiB (230 bytes). Some operating systems show the binary value but label it KB, MB or GB.

Why is the Bits and Bytes formula important in CS Thinking?

Bits and bytes let you predict things before they happen: how many photos fit on a phone, how long a download takes, why a color channel stops at 255. The common slip is mixing them up. A 50 Mbps connection moves about 6.25 megabytes a second, not 50, so a 500 MB game takes about 80 seconds to download, not 10.

What do students get wrong about Bits and Bytes?

KB, MB, GB are 1024× each other, not 1000× (though marketing often uses 1000).

What should I learn before the Bits and Bytes formula?

Before studying the Bits and Bytes formula, you should understand: binary.

The full guide

This formula is covered in depth in Computational Thinking Fundamentals: Dependency Graphs, Patterns, Bits and Bytes.