Paper 1 · Computer Systems 试卷一 · 计算机系统

1.3 · Data storage and compression

1.3 · 数据存储与压缩

Measuring storage, sizing files, and shrinking them

度量存储量、计算文件大小并压缩文件

Every file is a count of bits. This subtopic is about naming those quantities with the right units, working out how big an image or sound file will be, and reducing that size without wrecking the file.

每个文件本质上都是位的计数。本子主题的内容是:用正确的单位表示这些数量,计算出图像或声音文件的大小,并在不损坏文件的前提下缩小这个大小。

Core for all candidates 所有考生均需掌握的核心内容 Covers 1.3.1 to 1.3.4 涵盖 1.3.1 至 1.3.4 Calculation marks every series 每次考试都会考查计算题的分数

Explainer · 1.3.1

讲解 · 1.3.1

How data storage is measured

数据存储量的度量方式

A bit is a single binary digit, 0 or 1: the smallest thing a computer stores. Bits are grouped into larger named units.

位(bit)是一个二进制数字,0 或 1:是计算机存储的最小单位。多个位会被组合成更大的、具名的单位。

Unit单位 Size大小 In the previous unit相对于上一级单位
bit位(bit) one binary digit一个二进制数字 –
nibble半字节(nibble) 4 bits4 bits
byte字节(byte) 8 bits 2 nibbles (8 bits)2 个半字节(8 位)
kibibyte (KiB)千二进制字节(KiB) 210 bytes 1024 bytes
mebibyte (MiB)兆二进制字节(MiB) 220 bytes 1024 kibibytes
gibibyte (GiB)吉二进制字节(GiB) 230 bytes 1024 mebibytes
tebibyte (TiB)太二进制字节(TiB) 240 bytes 1024 gibibytes
pebibyte (PiB)拍二进制字节(PiB) 250 bytes 1024 tebibytes
exbibyte (EiB)艾二进制字节(EiB) 260 bytes 1024 pebibytes
!

Each step up from the kibibyte is × 1024, not × 1000. These are the binary prefixes (KiB, MiB, GiB…). The decimal prefixes you see on packaging (KB, MB, GB) step by 1000. The syllabus and the exam use the binary ones: always calculate with 1024.

从千二进制字节往上,每一级都是× 1024,而不是 × 1000。这些是二进制前缀(KiB、MiB、GiB……)。你在包装上看到的十进制前缀(KB、MB、GB)是按 1000 递增的。考纲和考试使用的是二进制前缀:务必用 1024 进行计算。

So there are 1024 kibibytes in 1 mebibyte, and 8 bits in 1 byte. To go from bits to bytes you divide by 8.

因此,1 兆二进制字节中有1024 个千二进制字节,1 字节中有8 个位。从位换算到字节需要除以 8。

Try it yourself

动手试试

The unit converter

单位换算器

Click a unit to see how it relates to the one below it. Then convert a value and watch the working: every step between byte-based units is a multiply or divide by 1024.

点击某个单位,查看它与下一级单位的关系。然后转换一个数值,观察运算过程:在以字节为基础的单位之间,每一步都是乘以或除以 1024。

    Explainer · 1.3.2

    讲解 · 1.3.2

    Calculating the file size of an image and a sound file

    计算图像和声音文件的文件大小

    Both calculations start by counting the total bits, then convert to whatever unit the question asks for.

    这两种计算都是先算出总位数,然后转换成题目要求的单位。

    File文件类型 Total bits总位数
    Image (bitmap)图像(位图) width × height × colour depth 宽 × 高 × 色深
    Sound (one channel)声音(单声道) sample rate × sample resolution × length in seconds 采样率 × 采样分辨率 × 时长(秒)

    Then: ÷ 8 for bytes, ÷ 1024 for kibibytes, ÷ 1024 again for mebibytes, and so on. Colour depth and sample resolution are given in bits; if a question gives them in bytes, multiply by 8 first.

    接下来:÷ 8 得到字节数,÷ 1024 得到千二进制字节数,再 ÷ 1024 得到兆二进制字节数,依此类推。色深和采样分辨率通常以位为单位给出;如果题目以字节给出,需先乘以 8。

    Marks are for the working 分数取决于运算过程

    Calculation questions award marks stage by stage. Show the pixel count, the bit count, the byte count and each ÷ 1024, even if the final number is wrong. A single line with just an answer throws away most of the marks.

    计算题是按步骤给分的。请展示像素数、位数、字节数以及每一次 ÷ 1024 的过程,即使最终答案是错的。只写一行答案会失去大部分分数。

    Try it yourself

    动手试试

    Image file size

    图像文件大小

    Set the resolution and colour depth. The working is laid out the way the exam wants it: pixels, then bits, then bytes, then each divide by 1024.

    设置分辨率和色深。运算过程会按照考试要求的方式展示:先像素,再位,再字节,然后每一步除以 1024。

      Try it yourself

      动手试试

      Sound file size

      声音文件大小

      Sample rate is samples per second, sample resolution is bits per sample. Multiply by the length in seconds for the bit total. Two channels (stereo) doubles it.

      采样率是每秒的样本数,采样分辨率是每个样本的位数。乘以时长(秒)即可得到总位数。双声道(立体声)会使其翻倍。

        Explainer · 1.3.3

        讲解 · 1.3.3

        The purpose of and need for data compression

        数据压缩的目的与必要性

        The calculations above show why: a few seconds of stereo sound or one photograph is already megabytes. Compression exists to reduce the size of a file. A smaller file means:

        上面的计算已经说明了原因:仅仅几秒钟的立体声音频,或者一张照片,文件大小就已经是数兆字节。压缩的目的就是缩小文件的大小。更小的文件意味着:

        Impact影响 Why it matters为什么重要
        Less storage space needed所需存储空间更少 more files fit on the same drive; cloud storage billed by size costs less 同一硬盘可存放更多文件;按容量计费的云存储费用更低
        Less bandwidth used占用的带宽更少 fewer bits cross the network, so a download uses up less of the available transfer rate 通过网络传输的位数更少,因此下载占用的可用传输速率也更少
        Shorter transmission time传输时间更短 fewer bits to send means a file uploads, downloads or streams faster 需要发送的位数更少,意味着文件上传、下载或流式传输的速度更快
        !

        “It makes the file smaller” is the definition, not an impact. When a question asks for the effect or the benefit, name a consequence of the smaller size: storage, bandwidth or transmission time.

        "使文件变小"是压缩的定义,而不是它的影响。当题目要求说明效果或好处时,应说明文件变小所带来的后果:存储空间、带宽或传输时间。

        Explainer · 1.3.4

        讲解 · 1.3.4

        Lossy and lossless compression

        有损压缩与无损压缩

        Lossy有损 Lossless无损
        What happens to the data数据发生了什么 data is permanently removed; the original file cannot be recovered 数据被永久移除;原始文件无法恢复 the file is made smaller with no permanent loss; the original file can be restored exactly 文件在不产生永久性丢失的情况下变小;原始文件可以被精确还原
        How it shrinks the file如何缩小文件 reduces image resolution or colour depth; reduces sound sample rate or resolution; discards detail a human is unlikely to notice 降低图像分辨率或色深;降低声音采样率或分辨率;舍弃人耳/人眼不太可能察觉的细节 records repeated or redundant data more efficiently, for example run length encoding (RLE) 更高效地记录重复或冗余的数据,例如行程长度编码(RLE)
        Good for适用于 photos, music and video, where a small quality drop is acceptable and small size matters 照片、音乐和视频,这些场合可以接受轻微的质量下降,且文件大小很重要 text, spreadsheets, program files, where losing any data would corrupt the file 文本、电子表格、程序文件,这些场合丢失任何数据都会损坏文件
        !

        “Lossy” and “lossless” are the two types. JPEG, MP3, MP4 and ZIP are examples of software or formats, not types. If a question asks for a type of compression, answer lossy or lossless.

        "有损"和"无损"是压缩的两种类型。JPEG、MP3、MP4 和 ZIP 是软件或格式的示例,而不是类型。如果题目要求说明压缩的类型,应回答"有损"或"无损"。

        Try it yourself

        动手试试

        Run length encoding

        行程长度编码

        RLE is lossless. It replaces a run of identical values with two numbers: how many, then which value. Paint the grid (click a cell to toggle it) and watch the encoded stream and the size saving. Notice RLE only helps when there are long runs.

        RLE 是一种无损压缩方法。它用两个数字替代一连串相同的值:数量,然后是数值。在网格上作画(点击单元格切换状态),观察编码后的数据流以及节省的空间。请注意,只有存在较长的连续段时,RLE 才有帮助。

        Check your understanding

        检验你的理解

        How many kibibytes (KiB) are there in 2 mebibytes (MiB)?

        2 兆二进制字节(MiB)中有多少个千二进制字节(KiB)?

        Check your understanding

        检验你的理解

        A question asks you to state a type of compression. Which answer is correct?

        题目要求你陈述一种压缩类型,下列哪个答案是正确的?

        Check your understanding

        检验你的理解

        Which statement is true of lossy compression?

        下列哪一项陈述对有损压缩是正确的?

        Common mistakes

        常见错误

        Markers reported these patterns for 1.3.1 / 1.3.2 / 1.3.3 / 1.3.4 考官针对 1.3.1 / 1.3.2 / 1.3.3 / 1.3.4 报告了以下模式

        RecurringCandidates confuse binary and decimal prefixes. A binary prefix (mebibyte, gibibyte) needs 1024 in the calculation; a decimal prefix (megabyte, gigabyte) needs 1000. The 0478 questions use binary prefixes.

        反复出现考生经常把二进制前缀和十进制前缀搞混。二进制前缀(兆二进制字节、吉二进制字节)在计算中需要用 1024;十进制前缀(兆字节、吉字节)需要用 1000。0478 的试题使用的是二进制前缀。

        In file-size calculations, two errors dominate: dividing by 1024 only once when the answer is asked for in mebibytes (it needs ÷ 1024 twice from bytes), and multiplying by 8 when converting bits to bytes instead of dividing. One report also notes candidates using 1 byte for a colour depth given as 2 bytes.

        在文件大小计算中,有两类错误最为常见:题目要求以兆二进制字节作答时只除以 1024 一次(从字节换算需要除以 1024 两次),以及把位转换为字节时用乘以 8 而不是除以 8。有一份报告还指出,考生把给定为 2 字节的色深当成 1 字节使用。

        Asked for a type of compression, candidates give an example (MP3, JPEG) or name a ZIP folder, which is not a compression method. The answer is lossy or lossless.

        题目要求说明压缩的类型时,考生给出的是示例(MP3、JPEG)或提到 ZIP 文件夹,而这并不是一种压缩方法。正确答案是有损或无损。

        Few candidates can explain how lossless compression reduces the size. The mechanism for RLE: a run of identical adjacent values is stored as two values, a count and the value itself, instead of repeating it.

        很少有考生能够解释无损压缩是如何缩小文件大小的。RLE 的原理是:一连串相邻且相同的值被存储为两个值,一个是数量,一个是该值本身,而不是重复存储每一个值。

        ✕

        Answer only: “File size = 12 MiB.” with no working shown.

        只给答案:"文件大小 = 12 MiB。"没有展示任何运算过程。

        ✓

        Staged working: “pixels = 2048 × 1536 = 3 145 728; bits = × 24 = 75 497 472; bytes = ÷ 8 = 9 437 184; KiB = ÷ 1024 = 9216; MiB = ÷ 1024 = 9.”

        分步展示运算:"像素 = 2048 × 1536 = 3 145 728;位 = × 24 = 75 497 472;字节 = ÷ 8 = 9 437 184;KiB = ÷ 1024 = 9216;MiB = ÷ 1024 = 9。"

        ✕

        Vague: “Lossless compression makes the file smaller without losing quality.”

        笼统含糊:"无损压缩能在不损失质量的情况下缩小文件。"

        ✓

        Mechanism: “Repeated adjacent values are replaced by a count and the value, so the same data is stored in fewer bytes and can be restored exactly.”

        说明原理:"相邻重复的值被替换为一个数量和该值本身,因此相同的数据用更少的字节存储,并且可以被精确还原。"

        Revision questions

        复习题

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

        采用历年真题风格。写下答案,然后展开评分要点给自己打分。

        Question 1 · 2 marks 第 1 题 · 2 分

        [2]State the number of bits in one nibble, and the number of kibibytes in one mebibyte.

        [2]陈述一个半字节中的位数,以及一个兆二进制字节中的千二进制字节数。

        Question 2 · 3 marks 第 2 题 · 3 分

        [3]An image is 2048 × 1536 pixels with a colour depth of 8 bits. Calculate its file size in kibibytes. Show your working.

        [3]一张图像分辨率为 2048 × 1536 像素,色深为 8 位。计算其以千二进制字节为单位的文件大小。请展示运算过程。

        Question 3 · 4 marks 第 3 题 · 4 分

        [4]A sound clip is sampled at 44 100 Hz using 16 bits per sample, in stereo, for 20 seconds. Calculate the file size in mebibytes.

        [4]一段声音以 44 100 Hz 的采样率、每个样本 16 位、立体声录制,时长 20 秒。计算其以兆二进制字节为单位的文件大小。

        Question 4 · 3 marks 第 4 题 · 3 分

        [3]Give three impacts of compressing a file before sending it as an email attachment.

        [3]给出将文件压缩后再作为电子邮件附件发送的三个影响。

        Question 5 · 4 marks 第 5 题 · 4 分

        [4]A user must send a legal document with no loss of any content. State which type of compression is suitable and explain how run length encoding would reduce the file size.

        [4]用户需要发送一份不能丢失任何内容的法律文件。陈述哪种类型的压缩适用,并解释行程长度编码如何缩小文件大小。

        Flashcards

        记忆卡片

        Active recall for this subtopic’s key terms.

        针对本子主题关键术语的主动回忆练习。

        Prototype render · content grounded in the Cambridge IGCSE 0478 syllabus and real 0478 examiner-report data for 1.3 · not yet wired to live routes