📚 Data Representation Key Points for A-Level CIE Computer Science | A-Level CIE 计算机:数据表示 考点精讲
Data representation is the backbone of all digital systems. This revision guide walks you through every critical concept required for the CIE A-Level Computer Science syllabus, from binary number systems and hexadecimal to floating-point numbers, text, images, and sound encoding. Each section pairs English explanations with their Chinese counterparts, ensuring you build both technical fluency and exam confidence.
数据表示是所有数字系统的基石。本复习指南将带你梳理 CIE A-Level 计算机科学考纲要求的每一个关键概念——从二进制和十六进制数制,到浮点数、文本、图像和声音的编码。每个部分均提供中英对照讲解,帮助你在掌握技术语言的同时,轻松应对考试。
1. Number Systems Overview | 数制系统概览
Digital computers store and process data using binary (base-2), which uses only the digits 0 and 1. However, humans find binary lengthy and hard to read, so we also rely on denary (base-10) for everyday use and hexadecimal (base-16) as a compact shorthand. Understanding the relationship among these three bases is fundamental to all further data representation topics.
数字计算机使用二进制(基数为 2)存储和处理数据,只使用数字 0 和 1。然而,人类觉得二进制冗长难读,因此我们日常使用十进制(基数为 10),并借助十六进制(基数为 16)作为一种紧凑的缩写形式。理解这三种基数之间的关系,是学习所有后续数据表示主题的基础。
The place values in binary are powers of 2 (…2³, 2², 2¹, 2⁰); in denary they are powers of 10; in hexadecimal they are powers of 16. Hexadecimal digits beyond 9 use the letters A–F to represent values 10–15.
二进制的位权是 2 的幂(…2³, 2², 2¹, 2⁰);十进制的位权是 10 的幂;十六进制的位权是 16 的幂。十六进制中大于 9 的数字用字母 A–F 表示,分别对应值 10–15。
2. Binary-Denary Conversion | 二进制与十进制的转换
To convert a binary number to denary, multiply each binary digit (bit) by its place value and sum the results. For example, 1101₂ = 1×8 + 1×4 + 0×2 + 1×1 = 13₁₀. For fractional binary numbers, use negative powers of 2 after the binary point: 10.101₂ = 1×2 + 0×1 + 1×½ + 0×¼ + 1×⅛ = 2.625₁₀.
将二进制数转换为十进制,需要用每个二进制位乘以它的位权,然后求和。例如,1101₂ = 1×8 + 1×4 + 0×2 + 1×1 = 13₁₀。对于带小数的二进制数,小数点后使用 2 的负幂:10.101₂ = 1×2 + 0×1 + 1×½ + 0×¼ + 1×⅛ = 2.625₁₀。
To convert a positive denary integer to binary, repeatedly divide by 2 and keep the remainders; read the remainders backwards to obtain the binary representation. For the fractional part, repeatedly multiply by 2 and record the integer part, continuing until the fraction becomes zero or a repeating pattern is observed.
将正整数从十进制转换为二进制,可以使用“除以 2 取余法”,将余数倒序排列即得二进制表示。对于小数部分,则“乘以 2 取整法”,直到小数部分为零或出现循环为止。
3. Hexadecimal Essentials | 十六进制核心要点
Hexadecimal provides a human-friendly way to represent binary strings. Each hex digit maps directly to a group of 4 bits (a nibble), so two hex digits represent one byte. This makes it much easier to read memory addresses, colour codes, and machine code without error.
十六进制为人类提供了一种友好的二进制表示方式。每个十六进制数字直接对应 4 个二进制位(一个半字节),因此两个十六进制数字就可以表示一个字节。这使得阅读内存地址、颜色代码和机器码变得容易得多,且不易出错。
- Binary to hex: group bits in fours from the right, pad with leading zeros if needed, then convert each group.
- 二进制转十六进制:从右向左每 4 位一组,必要时左侧补零,然后逐一转换为对应十六进制数字。
- Hex to binary: replace each hex digit with its 4-bit binary equivalent.
- 十六进制转二进制:将每一位十六进制数字替换为对应的 4 位二进制数。
- Hex to denary: multiply each digit by its place value (power of 16) and sum. E.g., 2F₁₆ = 2×16 + 15×1 = 47₁₀.
- 十六进制转十进制:每位乘以 16 的幂次再求和。例如 2F₁₆ = 2×16 + 15×1 = 47₁₀。
4. Binary Arithmetic and Overflow | 二进制算术与溢出
Binary addition follows simple rules: 0+0=0, 0+1=1, 1+0=1, 1+1=0 with a carry of 1 to the next higher bit. Subtraction can be performed as the addition of a two’s complement (covered later) or by borrowing if using the direct method.
二进制加法遵循简单规则:0+0=0,0+1=1,1+0=1,1+1=0 并产生进位 1 到高位。减法可以通过加上二进制补码(稍后介绍)来实现,或者使用借位法直接相减。
Overflow occurs when the result of an operation exceeds the range that can be stored in the given number of bits. In an 8-bit signed two’s complement system, numbers range from -128 to +127. Adding 64 and 65 (both +ve) gives 129, which would appear as a negative number because the sign bit becomes 1 — this is overflow. Exams often ask you to detect overflow by comparing the carry into the sign bit with the carry out.
当运算结果超出给定二进制位数所能表示的范围时,就会发生溢出。在 8 位补码系统中,表示范围是 -128 到 +127。若将 64 和 65(均为正数)相加,结果为 129,但由于符号位变为 1,显示为负数——这就是溢出。考试常常要求你通过比较进入符号位的进位和离开符号位的进位来检测溢出。
5. Two’s Complement Representation | 二进制补码表示法
Two’s complement is the standard method for representing signed integers in binary. It allows the same addition circuitry to handle both positive and negative numbers. In an n-bit system, the most significant bit (MSB) is the sign bit: 0 for positive, 1 for negative.
二进制补码是表示有符号整数的标准方法。它使同样的加法电路可以同时处理正数和负数。在 n 位系统中,最高位(MSB)是符号位:0 表示正,1 表示负。
To obtain the two’s complement of a binary number (i.e., its negative equivalent), invert all bits (one’s complement) and add 1 to the least significant bit. For example, the 8-bit two’s complement of +5 (00000101) is 11111011, which represents -5.
要得到一个二进制数的补码(即它的负数形式),先将所有位取反(反码),然后在最低位加 1。例如,+5 的 8 位二进制是 00000101,其补码为 11111011,表示 -5。
Range of n-bit two’s complement: -2ⁿ⁻¹ to 2ⁿ⁻¹ – 1. For 8 bits, -128 to +127. Conversion from a negative two’s complement to denary: if MSB is 1, find its two’s complement (positive magnitude), then add a negative sign.
n 位补码的表示范围:-2ⁿ⁻¹ 到 2ⁿ⁻¹ – 1。8 位补码便为 -128 到 +127。将负数的补码转换为十进制:若最高位为 1,先求其补码得到正数值,再加上负号。
6. Floating-Point Representation | 浮点数表示法
Computers use floating-point representation to store real numbers (numbers with fractional parts). The number is split into a mantissa (significand) and an exponent. This resembles scientific notation: a number = mantissa × base^(exponent). In binary, the base is 2.
计算机使用浮点数表示法来存储实数(带小数部分的数)。将数字拆分为尾数(有效数字)和指数。这与科学记数法类似:数字 = 尾数 × 基数^(指数)。二进制中基数为 2。
A typical layout allocates a fixed number of bits for the mantissa (including its sign) and the rest for the exponent (also two’s complement). Increasing the mantissa bits increases precision; increasing the exponent bits increases range. CIE learners must be able to normalise a floating-point number: a positive binary floating-point number is normalised when the MSB of its mantissa is 1; for negative numbers in two’s complement, normalisation requires the first two bits of the mantissa to be 10.
典型的浮点数格式为尾数(包含符号位)分配固定位数,其余位数给指数(同样使用补码)。增加尾数位数可以提高精度;增加指数位数可以扩大表示范围。CIE 学习者必须能够对浮点数进行规格化:对于正浮点数,尾数的最高位应为 1;对于使用补码表示的负数,规格化要求尾数的前两位为 10。
| Component | Meaning |
|---|---|
| Mantissa | Significand, holds the precision bits of the number. |
| Exponent | Scales the mantissa, stored in two’s complement form. |
Value = Mantissa × 2^(Exponent)
To convert a floating-point binary number to denary: multiply the mantissa by 2 raised to the power of the exponent, then convert the result. Normalisation maximises precision by eliminating leading zeros/ones.
将二进制浮点数转换为十进制:先计算尾数 × 2^(指数) 的值,再把结果转为十进制。规格化通过消除前导零/一来最大化精度。
7. Character Encoding – ASCII and Unicode | 字符编码 – ASCII 与 Unicode
Characters are stored in memory as numerical codes. The 7-bit ASCII standard defines 128 characters, covering English letters, digits, punctuation, and control codes. Extended ASCII uses 8 bits to provide an additional 128 characters, typically for accented letters and line-drawing symbols.
字符在内存中以数值代码的形式存储。7 位 ASCII 标准定义了 128 个字符,涵盖英文字母、数字、标点符号和控制字符。扩展 ASCII 使用 8 位,额外提供 128 个字符,通常用于重音字母和制表符号。
Unicode was developed to support virtually all writing systems. It uses code points ranging from U+0000 to U+10FFFF. Encoding forms such as UTF-8, UTF-16, and UTF-32 define how these code points are mapped to byte sequences. UTF-8 is backward compatible with ASCII and uses 1–4 bytes per character, making it dominant on the web.
Unicode 的诞生是为了支持几乎所有书写系统。它使用从 U+0000 到 U+10FFFF 的码点。UTF-8、UTF-16 和 UTF-32 等编码形式定义了如何将这些码点映射为字节序列。UTF-8 向下兼容 ASCII,每个字符使用 1–4 字节,因此在网络上占主导地位。
Exam focus: you should be able to explain why Unicode is superior for international applications, and compare storage requirements of different encoding schemes.
考试重点:需要能够解释为何 Unicode 在国际化应用中更优越,并能比较不同编码方案的存储需求。
8. Representing Images – Bitmaps and Vectors | 图像表示 – 位图与矢量图
Images are represented digitally in two main forms: bitmapped (raster) graphics and vector graphics. A bitmap is a grid of pixels, each assigned a binary value representing its colour. Two key parameters are resolution (the number of pixels per unit, e.g., pixels per inch) and colour depth (bits per pixel). The file size of an uncompressed bitmap can be estimated as: width × height × colour depth (in bits).
数字图像主要有两种表示形式:位图(光栅)图形和矢量图形。位图是由像素组成的网格,每个像素分配一个二进制值来表示其颜色。两个关键参数是分辨率(每单位像素数,如每英寸像素数)和色深(每像素位数)。未压缩位图的文件大小可以估算为:宽度 × 高度 × 色深(以位为单位)。
Colour depth dictates the number of available colours: 1 bit → 2 colours, 8 bits → 256 colours, 24 bits (true colour) → approximately 16.7 million colours. Metadata (e.g., dimensions, colour table) also contributes to the file size.
色深决定了可用颜色的数量:1 位 → 2 色,8 位 → 256 色,24 位(真彩色)→ 约 1670 万色。元数据(例如尺寸、颜色表)也会增加文件大小。
Vector graphics store images as a set of geometric primitives (lines, circles, curves) described by mathematical formulas. They scale without quality loss and generally require less storage for diagrams and logos. In contrast, bitmaps lose quality when enlarged (pixelation).
矢量图形将图像存储为一组由数学公式描述的几何图元(线条、圆、曲线)。矢量图缩放不会损失质量,并且对于图表和标志通常占用更少的存储空间。相反,位图在放大时会出现质量下降(像素化)。
9. Representing Sound | 声音的表示
Sound is an analogue signal that must be converted to digital form via sampling. An analogue-to-digital converter (ADC) takes measurements of the sound wave’s amplitude at regular intervals. Two parameters dominate: sampling rate (number of samples per second, in Hz) and sampling resolution (bits per sample).
声音是模拟信号,必须通过采样转换为数字形式。模数转换器(ADC)以固定的时间间隔测量声波的振幅。两个主要参数是:采样率(每秒采样次数,单位 Hz)和采样分辨率(每个样本的位数)。
The Nyquist theorem states that the sampling rate must be at least twice the highest frequency present in the sound to avoid aliasing. Higher sampling rates and higher bit depths improve fidelity but increase file size. A common quality benchmark is CD audio: 44.1 kHz sampling rate and 16-bit resolution.
奈奎斯特定理指出,采样率至少应为声音中最高频率的两倍,以避免混叠现象。更高的采样率和更大的位深度可以提升保真度,但会增加文件大小。常见的高品质基准是 CD 音频:44.1 kHz 采样率,16 位分辨率。
File size for uncompressed mono sound in bits = sampling rate (Hz) × bit depth × duration (seconds). For stereo, multiply by 2. Exams often require you to calculate file sizes and discuss trade-offs between quality and storage.
未压缩单声道声音文件的大小(以位为单位)= 采样率 (Hz) × 采样精度 (位) × 时长 (秒)。立体声则需乘以 2。考试常常要求计算文件大小,并讨论质量与存储之间的权衡。
10. Data Compression – Lossy vs Lossless | 数据压缩 – 有损与无损
Data compression reduces the number of bits needed to store or transmit information. There are two families: lossless compression, which allows exact reconstruction of the original data, and lossy compression, which discards some information to achieve higher compression ratios, acceptable for media where slight imperfections are imperceptible.
数据压缩减少了存储或传输信息所需的位数。分为两类:无损压缩,可以精确重建原始数据;有损压缩,丢弃部分信息以换取更高的压缩比,适用于轻微失真不易察觉的媒体。
Run-length encoding (RLE) is a simple lossless method suited for images with large uniform blocks. It replaces sequences of identical pixels with a count and the colour value. For example, ‘AAAAABBB’ becomes ‘5A3B’. Dictionary-based methods like LZ77/LZ78 are used in ZIP files. Huffman coding uses variable-length codes based on frequency.
行程编码(RLE)是一种简单的无损方法,适合有大面积同色块的图像。它将连续的相同像素序列替换为一个计数值和颜色值。例如 ‘AAAAABBB’ 压缩为 ‘5A3B’。ZIP 文件使用的是基于字典的 LZ77/LZ78 等方法。哈夫曼编码则采用基于出现频率的变长码。
Lossy compression is essential for JPEG images and MP3 audio. JPEG uses the discrete cosine transform (DCT) to convert spatial data into frequency components and then quantises high-frequency data more coarsely. MP3 exploits psychoacoustic models to remove sounds masked by louder ones. For both, the exam expects you to explain the principles, not implement the algorithms.
有损压缩对于 JPEG 图像和 MP3 音频至关重要。JPEG 使用离散余弦变换(DCT)将空间数据转换为频率分量,然后粗略量化高频数据。MP3 利用心理声学模型,去除被更大声音掩盖的声音。考试只需解释原理,不要求实现算法。
11. Error Detection and Correction Basics | 错误检测与纠正基础
When data is transmitted or stored, errors may occur. Common detection methods include parity bits (odd/even parity) and checksums. A parity bit is added to a byte to make the number of 1s even (even parity) or odd (odd parity). Parity can detect single-bit errors but not two-bit errors; it provides no correction.
数据在传输或存储过程中可能发生错误。常见的检测方法包括奇偶校验位(奇/偶校验)和校验和。校验位被添加到字节中,使 1 的个数为偶数(偶校验)或奇数(奇校验)。奇偶校验能够检测单比特错误,但无法检测双比特错误,且不能纠正错误。
Checksums involve summing blocks of data and sending the sum; the receiver recomputes and compares. For greater reliability, cyclic redundancy checks (CRC) treat data as a polynomial and divide by a generator polynomial, appending the remainder. CRC catches burst errors effectively.
校验和的方法是将数据块求和并发送和值;接收端重新计算并比较。为了更高的可靠性,循环冗余校验(CRC)将数据视为多项式,除以生成多项式,并将余数附加到数据后。CRC 能够有效检测突发错误。
Forward error correction, such as Hamming codes, allows both detection and correction of errors. While CIE does not require deep implementation, you should understand the concept of redundancy and be able to explain why parity is limited.
前向纠错,如汉明码,既能检测也能纠正错误。虽然 CIE 不要求深入实现细节,但你应该理解冗余的概念,并能够解释为什么奇偶校验功能有限。
12. Typical Exam Pitfalls and Tips | 常见考试陷阱与技巧
When converting between bases, always show your working — marks are awarded for method. In two’s complement questions, clearly indicate the sign bit and check for overflow. For floating-point normalisation, remember that a positive mantissa must start with ’01.’ after the binary point, and a negative one must start with ’10.’.
进行数制转换时,务必展示计算过程——方法步骤是给分点。在补码问题中,清晰标出符号位并检查溢出。对于浮点数规格化,请记住正尾数的小数点后必须以 ’01.’ 开头,负尾数必须以 ’10.’ 开头。
- Don’t confuse data units: a byte is 8 bits, a kibibyte (KiB) is 2¹⁰ bytes, not 1000.
- 不要混淆数据单位:1 字节等于 8 位,1 kibibyte (KiB) 是 2¹⁰ 字节,而非 1000。
- When computing image or sound file sizes, convert everything to bits first and only at the end convert to larger units if asked.
- 计算图像或声音文件大小时,先将所有数值统一到位,最后再按要求转换为更大单位。
- Read hexadecimal carefully: B is 11, D is 13, watch for misreading.
- 仔细阅读十六进制数字:B 是 11,D 是 13,防止误读。
Published by TutorHao | Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导