First exams 2027 · SL & HL 2027 年首次开考 · SL 与 HL

A1.2.2 · Computer fundamentals

A1.2.2 · 计算机基础

How Binary Is Used to Store Data

二进制如何用来存储数据

A computer only stores bits. A number, a letter, a photo, a song and a film are all the same kind of thing to it: a long run of 0s and 1s. What makes one a photo and another a song is the agreed scheme for reading the bits back.

计算机只存储位。一个数字、一个字母、一张照片、一首歌和一部电影,对它来说都是同一种东西:一长串 0 和 1。让其中一个成为照片、另一个成为歌曲的,是读回这些位时所用的约定方案。

A1's guiding question asks what principles underpin how a computer works. One: a single encoding scheme, agreed in advance, is what turns raw bits into meaning, and the scheme chosen decides how much space the data takes and how quickly it can be searched.

A1 的引导性问题问的是支撑计算机运行的原理。其一:一个事先约定好的编码方案,才是把原始的位变成意义的东西,而所选的方案决定了数据占用多少空间、以及能多快被检索。

Core for SL & HL SL 与 HL 核心内容 Typically 2–5 marks · AO3 通常 2–5 分 · AO3 Command term: explain 命令词:explain(解释)

Explainer

讲解

The same bits, different meanings

同样的位,不同的含义

Df

Binary encoding is an agreed rule that maps each pattern of bits to a meaning. The byte 01000001 is the number 65, the letter A, or one grey level, depending only on which rule is being applied. Without the rule, the bits say nothing.

二进制编码是一条约定的规则,把每一种位的组合对应到一个含义。字节 01000001 是数字 65、字母 A,还是某个灰度值,完全取决于正在应用哪条规则。没有规则,这些位什么也不表示。

Two things follow from the scheme 方案带来两个后果

Storage: the number of bits per item (per character, per pixel, per sample) fixes the file size. Retrieval: a fixed-length scheme lets the computer jump straight to item number n by multiplying, while a variable-length scheme has to be read from the start.

存储:每个单元(每个字符、每个像素、每个采样)用多少位,决定了文件大小。检索:定长方案让计算机可以用乘法直接跳到第 n 个单元,而变长方案必须从头开始读。

Explore

探索

How each data type is stored in binary

每种数据类型如何用二进制存储

The syllabus names six: integers, characters and strings, images, audio and video. Click each one to see the mechanism and the parameter that controls its size.

考纲点名了六类:整数、字符和字符串、图像、音频和视频。点击每一类,看看它的存储机制,以及决定它大小的那个参数。

Try it yourself

动手试试

A character to binary

把一个字符变成二进制

Type any single character, or pick one below. The page looks up its code-point number (ASCII where it fits, Unicode otherwise) and shows that number in binary.

输入任意一个字符,或在下方挑一个。页面会查出它的码点编号(能放进 ASCII 的就用 ASCII,否则用 Unicode),并把这个编号显示为二进制。

Letters a to z and A to Z sit in a block: each capital is exactly 32 less than its lowercase partner, which is why flipping one bit (the 32s bit) changes case. Characters beyond the basic Latin set need a larger Unicode number and more than one byte.

字母 a 到 z 和 A 到 Z 排成一段:每个大写字母正好比它对应的小写字母小 32,所以翻转一个位(32 那一位)就能改变大小写。基本拉丁字母以外的字符需要更大的 Unicode 编号和不止一个字节。

Explainer

讲解

Effect on storage and retrieval

对存储和检索的影响

Choice in the schemeEffect on storageEffect on retrieval
More bits per item (higher colour depth, higher bit depth, wider integers)Larger files, slower to copy or sendEach item takes longer to read and process
Fixed length per item (8-bit ASCII, 32-bit integers)Predictable size, sometimes wasteful for small valuesItem n is found instantly by multiplying n by the item size
Variable length per item (UTF-8 text, compressed media)Smaller for common cases, no wasted spaceMust be scanned from the start; cannot jump to item n directly
Encoding designed for indexing (sorted keys, hashed values)Small overhead for the index structureLarge data sets can be searched quickly rather than element by element
方案中的选择对存储的影响对检索的影响
每个单元用更多位(更高的色深、更高的位深、更宽的整数)文件更大,复制或传输更慢每个单元读取和处理都更慢
每个单元定长(8 位 ASCII、32 位整数)大小可预测,对小的值有时会浪费把 n 乘以单元大小,就能立即定位第 n 个单元
每个单元变长(UTF-8 文本、压缩后的媒体)常见情况下更小,不浪费空间必须从头扫描;不能直接跳到第 n 个单元
为便于索引而设计的编码(有序的键、哈希后的值)索引结构有少量额外开销大数据集可以快速搜索,而不必逐个元素查找

Error detection is often built into the scheme too: a parity bit added to each byte lets a later read catch a single flipped bit, which matters for reliable retrieval from storage or over a network.

方案里通常还内建了错误检测:给每个字节加一个奇偶校验位,之后读取时就能发现一个被翻转的位,这对从存储介质或通过网络可靠地取回数据很重要。

Check your understanding

检验你的理解

A bitmap image is changed from 8-bit colour depth to 16-bit, with the same dimensions. What happens?

一张位图的色深从 8 位改为 16 位,尺寸不变。会发生什么?

Common mistake

常见错误

Recurring pattern in "explain how X is stored" answers "解释 X 如何存储"类答案中反复出现的模式

RecurringAnswers name a file format ("it is saved as a JPEG", "it is an MP3") and stop there. The command term is explain, so the marks are for the mechanism: an image is a grid of pixels, each pixel a set of bits giving its colour; audio is the wave measured many times a second, each measurement a binary number; video is a sequence of those images shown fast. A second slip: writing "colour depth" when the answer needs "number of colours", or the reverse. Colour depth is the bit count; the number of colours is 2 raised to that count.

反复出现答案说出一个文件格式("它存成 JPEG""它是 MP3")就停下了。命令词是 explain,所以分数是给机制的:图像是一个像素网格,每个像素是一组给出其颜色的位;音频是把声波每秒测量许多次,每次测量是一个二进制数;视频是把这些图像快速连续播放的序列。第二个错误:该说"颜色数"时写成"色深",或反过来。色深是位数;颜色数是 2 的该位数次方。

✕

Wrong: "A photo is stored in binary by saving it as a JPEG file, and sound is stored as an MP3."

错误: "照片通过存成 JPEG 文件的方式用二进制存储,声音存成 MP3。"

✓

Right: "A photo is a grid of pixels. Each pixel stores a binary number for its colour, for example three 8-bit values for red, green and blue. Sound is sampled: its level is measured thousands of times a second and each measurement is stored as a binary number whose range is set by the bit depth."

正确: "照片是一个像素网格。每个像素为它的颜色存储一个二进制数,例如红、绿、蓝三个 8 位的值。声音被采样:它的电平每秒被测量数千次,每次测量存成一个二进制数,其取值范围由位深决定。"

Revision questions

复习题

Specimen-paper style. Write an answer, then reveal the marking points and mark yourself.

采用样卷风格。写下答案,然后展开评分要点给自己打分。

Question 1 · 2 marks 第 1 题 · 2 分

[2]Explain why the same 8 bits can represent both a number and a character.

[2]解释为什么同样的 8 个位既能表示一个数,又能表示一个字符。

Question 2 · 3 marks 第 2 题 · 3 分

[3]Describe how a bitmap image is represented in binary.

[3]描述位图如何用二进制表示。

Question 3 · 4 marks 第 3 题 · 4 分

[4]Explain how sound is converted to and stored in binary, referring to sampling rate and bit depth.

[4]解释声音如何转换成二进制并存储,提到采样率和位深。

Question 4 · 4 marks 第 4 题 · 4 分

[4]Explain how the choice of a fixed-length versus a variable-length encoding affects both the size of a file and the speed of finding an item within it.

[4]解释选择定长编码还是变长编码,如何影响文件的大小以及在其中查找某个单元的速度。

Question 5 · 3 marks 第 5 题 · 3 分

[3]Explain why storing video as a plain sequence of full images is impractical, and name the two kinds of redundancy that compression removes.

[3]解释为什么把视频存成一串完整图像不切实际,并说出压缩去除的两种冗余。

Flashcards

记忆卡片

Active recall for this statement’s key terms.

针对本条考纲陈述关键术语的主动回忆练习。

Prototype render · grounded in the IB CS 2027 subject guide and the Hodder and Oxford IB CS 2027 texts for A1.2.2 · not yet wired to live routes