Unit 1: Digital information · Bits and bytes

Article

Everything is bits

5 min read

Open a photo on your phone. Play a song. Send a message. They look and sound nothing alike, but inside the phone they are all stored in the same way: as long lists of 0s and 1s. This article shows you the smallest piece of that idea.

A bit is one switch

A bit is a single binary digit. "Binary" means "made of two". A bit has only two possible values: 0 or 1.

Think of a light switch. It is off or on. There is no third setting. A bit is the same: it is always one of two values, and we write them as 0 and 1.

A computer is built from a huge number of tiny parts that can be in one of two states. Different parts can store a bit:

PartStores a 0Stores a 1
A switchoffon
A wirelow voltagehigh voltage
A tiny magnetpoints one waypoints the other way
A spot on a discreflects less lightreflects more light

The parts are different, but what they store is the same: a 0 or a 1. Try it below. Click the bits to flip them.

Pattern 00 is one of 4 different patterns 2 bits can make (22).

Check your understanding

What is a bit?

The same bits can mean different things

One bit holds very little. But a sequence of bits, many bits in a row, can hold a lot. Computers use sequences of bits to store numbers, letters, colours, sounds and more.

The bits do not say what they mean. The program that reads them decides. Here is one sequence of eight bits, read by two different programs:

Bits:                      0 1 0 0 0 0 0 1
 
A number program shows:    65
A text program shows:      A

You will learn later how a number or a letter is turned into bits. For now, notice only this: the same bits can be read in more than one way.

Check your understanding

The bit pattern 0110 is saved on a phone. One app reads it as part of a number. Another app reads it as part of a picture. What does this show?

Why only two values?

Imagine a wire that carries electricity. It is easy to tell "a lot of voltage" from "very little voltage", even when there is some small error or noise. It is much harder to tell ten different voltage levels apart. Two values are simple and reliable, so computers use them.

There is another useful idea here. When you think about a bit, you do not think about voltages, magnets or light. You just think "0 or 1". Ignoring the details you do not need, so you can focus on what matters, is called abstraction. Bits are an abstraction: they hide how the device really works.

From a photo down to a switch

  1. What you see

    a photo, a song, a message

  2. Data

    numbers, letters, colours and sounds

  3. Bits

    just 0s and 1s

  4. Hardware

    switches, voltages, magnets

A programmer thinks about the bits layer only. The hardware below it can change without changing the bits.

Worked example: phone settings

A phone stores three yes/no settings in this order: Wi-Fi, Bluetooth, torch. We choose 1 for "on" and 0 for "off".

SettingStateBit
Wi-Fion1
Bluetoothoff0
Torchoff0

The phone stores the sequence 100. If you switch Bluetooth on, only the middle bit changes, so the sequence becomes 110. Three settings need three bits, because each bit holds only one yes/no answer.

The whole unit on one page

This unit follows one story: how everything a computer holds becomes bits, and what that means. Come back to this map whenever you want to see where a lesson belongs.

Digital information
  • Bits and bytes

    • a bit is 0 or 1
    • a byte is 8 bits
    • n bits make 2^n values
  • Binary numbers

    • places are worth 1 2 4 8
    • converting to and from decimal
    • patterns such as odd and even
  • Limits of numbers

    • overflow when a result is too big
    • roundoff when a number is not exact
  • Text in binary

    • each character gets a number
    • the number is stored in bits
  • Analog to binary

    • sampling measures at regular times
    • more samples give a closer copy
  • Lossless compression

    • fewer bits
    • the original comes back exactly
  • Lossy compression

    • fewer bits
    • some detail is gone for good
  • Copyright and licences

    • who owns a work
    • Creative Commons and open source

Common mistakes

  • Thinking a bit can be 2, 3 or 9. A bit is only 0 or 1.
  • Thinking 0 means "nothing is stored". 0 is a real value, just like 1.
  • Thinking bits are only for numbers. A bit is not a number or a letter by itself. The meaning comes from how a program reads the bits.
  • Mixing up the order. In a sequence, each position has its own meaning. 100 and 001 are different sequences.

On the exam

You may be asked to say that all digital data, such as text, images and sound, is stored as bits, and that the same bits can be interpreted in different ways. Read the question carefully: it often describes a device and asks what the computer actually stores.

Key words

Bit: a binary digit. It is either 0 or 1.

Binary: made of two values only.

Sequence of bits: several bits in a row, in a fixed order.

Abstraction: leaving out details you do not need, so you can think about the idea that matters.

AP® is a trademark registered by the College Board, which is not affiliated with, and does not endorse, this site. All lessons and questions here are written by JrCodex.