Secondary Computer Science / 1.1 Digital Patterns and Number Codes

1.1.1 Two States, Many Patterns

🔒 Lesson slides are available to signed-in users. Sign in

1.1.1 Two States, Many Patterns

A smart building contains many computer-controlled systems. A door sensor may report open or closed. A security light may be on or off. A smoke detector may report clear or alarm.

Each example has two clearly different states. Computer circuits can represent these states using the symbols 0 and 1. By combining many binary digits, a computer can create enough patterns to represent numbers, text, images, sound, instructions and other forms of data.

By the end of this section, you should be able to:

  • explain why two-state representation is suitable for computer hardware;
  • define a bit and recognise a bit pattern;
  • determine how many different patterns can be formed using a given number of bits;
  • explain why the meaning of a bit pattern depends on an agreed encoding;
  • describe the basic roles of logic gates and registers.

Finding two distinct states

Electronic systems often need to distinguish between alternatives. A system is easier to control when each alternative can be detected reliably.

System State A State B Possible binary code
Window sensor Closed Open 0 or 1
Warehouse beam Clear Blocked 0 or 1
Cooling fan Stopped Running 0 or 1
Access check Denied Allowed 0 or 1
State 状态: one of the conditions in which a system or component can currently exist.

The symbols 0 and 1 are labels. A designer decides which physical condition each symbol represents. For one circuit, 1 may represent a higher voltage range. In another system, 1 might represent that a switch is closed or that a condition is true.

Common mistake

Do not assume that 1 always means “on” and 0 always means “off”. Their meanings depend on how the system has been designed. What matters is that the two states can be distinguished.

Why computer hardware uses binary

Inside a computer, electronic components work with electrical signals. Real signals are not always perfectly identical: small changes can be caused by temperature, electrical interference or differences between components.

Instead of requiring a circuit to recognise many extremely precise signal levels, computer hardware can classify signals into two broad and reliably distinguishable states. These states are represented using 0 and 1.

Binary 二进制: a representation system based on two symbols, normally 0 and 1.

Advantages of using two states

Feature Why it is useful
Two clearly separated conditions The hardware can distinguish one state from the other reliably.
Simple logical rules Circuits can combine binary inputs to make decisions.
Repeatable patterns The same sequence of bits can be copied, stored and transmitted.
Scalable representation Adding more bits creates many more available patterns.

Answer-building tip

A developed explanation should connect the representation to the hardware:

Computer circuits can distinguish between two physical states reliably, so the states can be represented using the binary symbols 0 and 1.

Avoid writing only “computers use binary because they understand 0 and 1”. Explain what makes two states suitable for electronic circuits.

From one state to one bit

Bit 位(比特): one binary digit. Its value is either 0 or 1.
Bit pattern 位模式: an ordered sequence made from several bits.

A single bit has two possible patterns:

0 or 1

When a second bit is added, each first-bit choice can be combined with both possibilities for the second bit:

Pattern First bit Second bit
00 0 0
01 0 1
10 1 0
11 1 1

Two bits therefore create four different patterns. Every additional bit doubles the number of available patterns.

With n bits, the number of possible patterns is: 2n
Number of bits Calculation Possible patterns
1 21 2
2 22 4
3 23 8
4 24 16
5 25 32

Common mistake

Four bits do not create eight patterns. Each bit has two possibilities, so the calculation is 2 × 2 × 2 × 2 = 16.

Worked example: a stage-lighting controller

A small theatre uses four switches to control four lighting features:

  1. front lights;
  2. background lights;
  3. floor lights;
  4. sign lights.

Each feature has two possible states, so one bit can be assigned to each feature.

Bit position Feature 0 represents 1 represents
First Front lights Off On
Second Background lights Off On
Third Floor lights Off On
Fourth Sign lights Off On

Step 1: count the bits

Four independent features require four bits.

Step 2: calculate the number of patterns

24 = 16 possible lighting patterns

Step 3: interpret one pattern

Consider the pattern 1011.

Feature Bit Result
Front lights 1 On
Background lights 0 Off
Floor lights 1 On
Sign lights 1 On

Answer-building tip

When calculating the number of patterns, state both the method and the result: “There are four bits, so 24 = 16 different patterns.”

Bits need an agreed meaning

A pattern such as 0110 does not have one automatic meaning. The computer system needs rules that explain how the pattern should be interpreted. These rules form an encoding.

Encoding 编码: an agreed system that maps data or instructions to particular bit patterns.
Data representation 数据表示: the method used to store or communicate information using symbols such as bits.
Possible interpretation of 0110 Meaning
Four equipment switches The second and third pieces of equipment are active.
Four black-and-white pixels Two pixels use one colour and two use the other colour.
A command code The pattern selects one operation from an agreed collection.
Part of a character code The bits contribute to a code representing a letter or symbol.

The same bits can therefore represent different information in different systems. Their meaning comes from the rules used to interpret them.

Common mistake

A computer does not discover the meaning of a pattern simply by looking at the bits. Software and hardware must use an agreed representation. Without that context, 0110 is only a sequence of four bits.

How two symbols can represent many forms of data

Different data types use different encoding rules, but the final stored form is still a collection of bits.

Data presented to a user How it can be represented internally Studied later in
Positive number A pattern interpreted using binary place values 1.1.2
Letter or symbol A bit pattern assigned through a character set 1.2.1
Digital image Bit patterns describing the colours of pixels 1.2.2
Recorded sound Bit patterns representing measurements of a sound wave 1.2.3
Program instruction A predefined pattern that identifies an operation Later processor topics

This explains why binary can be used for every form of data. The bits remain 0s and 1s, but the interpretation changes according to the encoding being used.

Processing and holding binary data

After information has been represented using bits, computer hardware must be able to process and temporarily hold those bits.

Logic gate 逻辑门: an electronic circuit that applies a logical rule to one or more binary inputs and produces a binary output.

Register 寄存器: a small, very fast storage location inside a processor that temporarily holds data, instructions or intermediate results.
1 Input

A sensor, stored file or input device supplies information.

2 Binary representation

The information is encoded as a pattern of 0s and 1s.

3 Logic gates

Electronic circuits process the binary inputs.

4 Register

A bit pattern may be held temporarily while processing continues.

5 Output

The result may control hardware, update a display or be stored.

Common mistake

A register is not the same as a complete storage drive. A register holds a relatively small amount of binary data inside the processor for immediate use.

Answer-building tip

When explaining what happens to binary data, use accurate verbs: logic gates process data and registers temporarily hold data.

Interactive: Binary Pattern Laboratory

Use the switches to investigate how adding bits changes the number of possible patterns. You can inspect individual patterns, play an animated sequence or complete a target-pattern challenge.

Interactive investigation

Build patterns using two states

Available patterns 8 2³ = 8
1. Choose the number of bits

2. Change the states

Current bit pattern 000 All three switches are in state 0.

What is happening?

  1. Each switch has two possible states.
  2. The states are represented using 0 and 1.
  3. The ordered switch states form one bit pattern.
  4. Adding one more bit doubles the total number of patterns.
Animation status Select “Play all patterns” to watch the sequence.

Pattern challenge

Can you match the target?

Set the switches so that the current pattern matches:

---

Select “New target” to begin.

Think before calculating

The pattern total depends on the number of bit positions, not on how many switches currently show 1.

Practice

Core questions

  1. State the two symbols used in binary representation.
  2. Define the term bit.
  3. Explain why two-state representation is suitable for electronic computer hardware.
  4. List every possible pattern that can be formed using two bits.
  5. Calculate how many different patterns can be formed using five bits.
  6. A delivery robot records three conditions: door open or closed, motor moving or stopped, and route clear or blocked. How many different status patterns are possible?
  7. Explain why the pattern 1100 cannot be interpreted correctly unless its encoding is known.
  8. Describe one difference between a logic gate and a register.

Extension questions

  1. A controller must represent 20 different commands. Explain why four bits are not sufficient and five bits are sufficient.
  2. Explain how the same four-bit pattern could represent both a group of black-and-white pixels and the states of four sensors.
  3. Six independent warning sensors each have a safe state and a danger state. Calculate the total number of possible combined warning patterns.
Check the numerical answers
  1. Two bits produce four patterns: 00, 01, 10 and 11.
  2. Five bits produce 25 = 32 patterns.
  3. Three robot conditions produce 23 = 8 patterns.
  4. Four bits produce only 16 patterns, whereas five bits produce 32.
  5. Six sensors produce 26 = 64 patterns.

Review

Key ideas

  • Computer hardware represents information using two distinguishable states.
  • The two states are commonly labelled 0 and 1.
  • One binary digit is called a bit.
  • An ordered group of bits forms a bit pattern.
  • With n bits, 2n different patterns can be formed.
  • A pattern only becomes meaningful when an encoding explains how to interpret it.
  • Logic gates process binary inputs.
  • Registers temporarily hold binary data inside the processor.

Quick self-check

  1. Can I explain why two physical states are useful in computer hardware?
  2. Can I distinguish a bit from a bit pattern?
  3. Can I calculate the number of patterns formed by several bits?
  4. Can I explain why an encoding is needed?
  5. Can I distinguish the purpose of a logic gate from the purpose of a register?

One-sentence exit task

Complete this explanation:

Computers use binary because ____________________________________________, allowing data to be represented using ____________________________________.