Bits and Bytes Examples in CS Thinking

Start with the recap, study the fully worked examples, then use the practice problems to check your understanding of Bits and Bytes.

This page combines explanation, solved examples, and follow-up practice so you can move from recognition to confident problem-solving in CS Thinking.

Concept Recap

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.

A bit is the smallest piece of data. A byte is enough to store one character.

Read the full concept explanation β†’

How to Use These Examples

  • Read the first worked example with the solution open so the structure is clear.
  • Try the practice problems before revealing each solution.
  • Use the related concepts and background knowledge badges if you feel stuck.

What to Focus On

Core idea: All digital dataβ€”text, images, musicβ€”is ultimately stored as sequences of bits grouped into bytes.

Common stuck point: KB, MB, GB are 1024\times each other, not 1000\times (though marketing often uses 1000).

Sense of Study hint: When converting between bits and bytes, remember that 1 byte = 8 bits. To find how many values n bits can represent, compute 2^n. To convert storage units, use the chain: 1 KB = 1024 bytes, 1 MB = 1024 KB, 1 GB = 1024 MB.

Worked Examples

Example 1

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

Solution

  1. 1
    Step 1: Each bit can be 0 or 1. With 3 bits, the number of combinations is 2^3 = 8.
  2. 2
    Step 2: The patterns are: 000, 001, 010, 011, 100, 101, 110, 111.
  3. 3
    Step 3: These represent the values 0 through 7 in decimal. In general, n bits can represent 2^n different values.

Answer

8 different values (0 to 7): 000, 001, 010, 011, 100, 101, 110, 111.
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?

Practice Problems

Try these problems on your own first, then open the solution to compare your method.

Example 1

medium
An image is 800 Γ— 600 pixels. Each pixel uses 24 bits (8 bits each for red, green, blue). What is the uncompressed file size in megabytes?

Example 2

hard
A colour system uses 4 bits per colour channel (red, green, blue). (a) How many shades can each channel represent? (b) How many unique colours are possible in total? (c) Compare this to standard 8-bit-per-channel colour.

Related Concepts

Background Knowledge

These ideas may be useful before you work through the harder examples.

binary