📚 A-Level CCEA Computer Science: Data Representation | 数据表示 考点精讲
Data representation is the foundation of all computing systems, bridging the gap between human-readable information and the binary language of machines. In the CCEA A-Level Computer Science specification, understanding how numbers, text, images, and sound are encoded and manipulated is essential for both theory papers and practical programming. This article breaks down every key concept you need to master, from binary arithmetic to data compression, with clear explanations and exam-centric examples.
数据表示是所有计算系统的基础,它连接了人类可读信息与机器的二进制语言。在 CCEA A-Level 计算机科学大纲中,理解数字、文本、图像和声音如何编码及处理,对于理论考试和实践编程都至关重要。本文详细拆解你需要掌握的每个核心概念,从二进制运算到数据压缩,配有清晰的解释和贴近考点的示例。
1. Number Systems: Binary, Denary, and Hexadecimal | 数制:二进制、十进制与十六进制
Computers operate using the binary number system (base-2) because their circuits rely on two stable states: off (0) and on (1). The denary (base-10) system is what humans use in everyday life, while hexadecimal (base-16) provides a compact way to represent binary values, using digits 0-9 and letters A-F (10-15). Each hexadecimal digit represents exactly four binary digits (a nibble), making conversions more readable and less error-prone.
计算机使用二进制(基数为2)工作,因为电路依赖两种稳定状态:关(0)和开(1)。十进制(基数为10)是人类日常使用的系统,而十六进制(基数为16)提供了一种紧凑表示二进制值的方式,使用数字0-9和字母A-F(代表10-15)。每个十六进制数字恰好代表四位二进制位(一个半字节),这使得转换更易读且不易出错。
In CCEA exams, you must be comfortable recognising place values: for binary, powers of 2 ( … 128, 64, 32, 16, 8, 4, 2, 1) ; for hexadecimal, powers of 16. A common question asks you to convert a binary number like 1011 0011 to denary and hex. The denary value is 128+32+16+2+1 = 179, and the hex equivalent is B3, as 1011 is B and 0011 is 3.
在 CCEA 考试中,你必须熟练识别位权值:二进制的位权是2的幂(… 128, 64, 32, 16, 8, 4, 2, 1);十六进制的位权是16的幂。常见的题目要求将例如 1011 0011 的二进制数转换为十进制和十六进制。十进制值为 128+32+16+2+1 = 179,十六进制为 B3,因为 1011 是 B,0011 是 3。
2. Converting Between Number Systems | 数制之间的转换
To convert from denary to binary, repeatedly divide by 2 and record the remainders from bottom to top. For hexadecimal, repeatedly divide by 16; remainders greater than 9 are converted to A–F. Conversion between binary and hexadecimal is straightforward by grouping bits into nibbles from the right. To convert hexadecimal to denary, multiply each digit by its place value (16^n) and sum the results.
将十进制转换为二进制,重复除以2,余数从下往上记录。对于十六进制,重复除以16;大于9的余数转换为A-F。二进制与十六进制之间的转换很简单,将从右开始每四位二进制分组即可。将十六进制转换为十进制,将每位数字乘以其位权(16的n次幂)并求和。
For example, denary 345 to hex: 345 ÷ 16 = 21 remainder 9; 21 ÷ 16 = 1 remainder 5; 1 ÷ 16 = 0 remainder 1. Reading remainders upward gives 159 (hex). Binary 1111010001 grouped as 11 1101 0001 → 3 D 1, so hex 3D1. Always show working steps in your answer to gain method marks.
例如,十进制 345 转十六进制:345 ÷ 16 = 21 余 9;21 ÷ 16 = 1 余 5;1 ÷ 16 = 0 余 1。从下往上读取余数得到十六进制 159。二进制 1111010001 分组为 11 1101 0001 → 3 D 1,因此十六进制为 3D1。在答案中一定要展示计算步骤,以获得过程分。
3. Binary Arithmetic: Addition and Subtraction | 二进制算术:加法与减法
Binary addition follows simple rules: 0+0=0, 0+1=1, 1+0=1, 1+1=0 carry 1, 1+1+1=1 carry 1. When two 8-bit numbers are added, an overflow occurs if the result exceeds 255 (or the representable range). Overflow is indicated by a carry out of the most significant bit, which the CPU flags in the status register.
二进制加法遵循简单规则:0+0=0, 0+1=1, 1+0=1, 1+1=0 进位1, 1+1+1=1 进位1。当两个8位数相加时,如果结果超过255(或可表示的范围),就会发生溢出。溢出由最高位的进位指示,CPU在状态寄存器中进行标记。
Binary subtraction is performed using two’s complement (see next section) or by direct borrowing. For subtraction, you can complement to convert subtraction into addition, which simplifies hardware. For example, 0110 (6) minus 0010 (2): complement 0010 to 1110, add to 0110 → 10100; discard the extra carry gives 0100 (4).
二进制减法使用二进制补码(见下一节)或直接借位进行。对于减法,你可以取补码将减法转换为加法,简化硬件实现。例如,0110 (6) 减 0010 (2):将 0010 取补码得 1110,与 0110 相加 → 10100;丢弃额外进位得 0100 (4)。
4. Negative Numbers: Sign-and-Magnitude vs Two’s Complement | 负数:符号-幅值与二进制补码
Sign-and-magnitude uses the most significant bit (MSB) to represent the sign (0=positive, 1=negative) and the remaining bits for magnitude. However, this leads to two zeros (0000 0000 and 1000 0000) and complicates arithmetic. Two’s complement overcomes these issues by representing negative numbers as the complement of the positive number plus one. The MSB still indicates sign (1 for negative), and there is only one zero.
符号-幅值表示法使用最高位(MSB)表示符号(0=正,1=负),其余位表示数值。然而,这导致出现了两个零(0000 0000 和 1000 0000)并使算术复杂化。二进制补码通过将正数的补码加一来表示负数,克服了这些问题。最高位仍然表示符号(1为负),且只有一个零。
To find the two’s complement of a binary number: invert all bits (one’s complement) and add 1. For example, +5 in 8-bit is 0000 0101; -5 is 1111 1010 + 1 = 1111 1011. The range for 8-bit two’s complement is -128 to +127. CCEA questions often ask you to represent a negative denary number in two’s complement and perform subtraction using it.
求一个二进制数的二进制补码:将所有位取反(反码)后加1。例如,8位的 +5 是 0000 0101;-5 是 1111 1010 + 1 = 1111 1011。8位二进制补码的表示范围是 -128 到 +127。CCEA 题目经常要求用二进制补码表示负的十进制数,并用它进行减法运算。
5. Fixed Point and Floating Point Binary | 定点与浮点二进制
Fixed point binary represents fractional numbers by allocating a fixed number of bits for the integer part and the fractional part. For example, in an 8-bit number with 4 bits after the binary point, 0101.1100 equals 5.75 (4+1+0.5+0.25). The precision is constant, but the range is limited.
定点二进制通过为整数部分和小数部分分配固定数量的位来表示小数。例如,定点设在4位小数部分的8位数字中,0101.1100 等于 5.75(4+1+0.5+0.25)。精度恒定,但范围有限。
Floating point expands range by storing numbers in the form mantissa × 2^exponent. A typical 16-bit representation might use 10 bits for the mantissa and 6 bits for the exponent, both in two’s complement. The decimal value is calculated as mantissa × 2^exponent. Normalisation ensures maximum precision by adjusting the mantissa so that the most significant bit (after the sign) differs from the sign bit, eliminating leading zeros.
浮点数通过以 尾数 × 2^指数 的形式存储数字来扩展范围。典型的16位表示可能使用10位尾数和6位指数,均为二进制补码形式。十进制值的计算方法是 尾数 × 2^指数。规范化通过调整尾数,使得符号位之后的第一位与符号位不同,从而消除前导零,确保最大精度。
6. Character Encoding: ASCII and Unicode | 字符编码:ASCII 与 Unicode
ASCII (American Standard Code for Information Interchange) uses 7 or 8 bits to represent up to 128 or 256 characters, including letters, digits, punctuation, and control codes. For instance, ‘A’ is 65 (0100 0001), and ‘a’ is 97. Extended ASCII adds 128 additional characters for accented letters and symbols.
ASCII(美国信息交换标准代码)使用7或8位来表示最多128或256个字符,包括字母、数字、标点和控制码。例如,’A’ 是 65(0100 0001),’a’ 是 97。扩展 ASCII 增加了128个额外字符,用于带重音的字母和符号。
Unicode was developed to support a vast range of characters from different writing systems, using variable-length encodings like UTF-8 (1–4 bytes), UTF-16, and UTF-32. UTF-8 is backward-compatible with ASCII for the first 128 characters. In exams, you need to compare ASCII and Unicode in terms of storage size and character coverage. A typical answer: ASCII requires only 1 byte per character but is limited to English; Unicode supports global scripts at the cost of more storage per character.
Unicode 的开发旨在支持来自不同文字系统的广泛字符,使用可变长度编码,如 UTF-8(1-4字节)、UTF-16 和 UTF-32。UTF-8 的前128个字符与 ASCII 向后兼容。在考试中,你需要比较 ASCII 和 Unicode 在存储大小和字符覆盖范围方面的差异。典型答案:ASCII 每个字符仅需1字节,但仅限于英语;Unicode 支持全球文字,但每个字符占用更多存储空间。
7. Bitmapped Graphics | 位图图形
A bitmap image is composed of a grid of pixels, each assigned a binary code representing its colour. The colour depth determines how many bits are used per pixel: 1 bit for monochrome (2 colours), 8 bits for 256 colours, 24 bits for true colour (16.7 million colours). Resolution is the number of pixels in the grid (e.g., 1920×1080).
位图图像由像素网格组成,每个像素分配一个表示其颜色的二进制代码。颜色深度决定每像素使用的位数:1位用于单色(2色),8位用于256色,24位用于真彩色(1670万色)。分辨率是网格中的像素数(例如 1920×1080)。
File size (in bits) of an uncompressed bitmap can be calculated as: width × height × colour depth. Metadata (header information about dimensions, colour table) adds a small overhead. You may be asked to calculate storage requirements and suggest ways to reduce file size, such as reducing colour depth or resolution, or applying compression.
未压缩位图的文件大小(以位为单位)可计算为:宽度 × 高度 × 颜色深度。元数据(关于尺寸、颜色表的头信息)会增加少量开销。你可能需要计算存储需求,并提出减少文件大小的方法,例如降低颜色深度或分辨率,或应用压缩。
8. Representing Sound | 声音的表示
Sound is stored digitally by sampling the amplitude of the analogue wave at regular intervals. The sample rate (in Hz) determines how many samples are taken per second; typical rates are 44.1 kHz for CD quality. Sample resolution (bit depth) determines the number of possible amplitude levels (e.g., 16-bit gives 65,536 levels). Higher sample rates and resolutions improve fidelity but increase file size.
声音通过以固定间隔对模拟波形的幅度进行采样来数字化存储。采样率(以赫兹为单位)决定每秒采集多少样本;CD 质量的典型采样率为 44.1 kHz。样本分辨率(位深度)决定可能的幅度级别数量(例如,16位提供 65,536 级)。更高的采样率和分辨率可提高保真度,但会增加文件大小。
File size for uncompressed mono sound = sample rate × sample resolution × duration. For stereo, multiply by 2. The Nyquist theorem states that the sampling frequency must be at least twice the highest frequency in the sound to avoid aliasing. In CCEA exams, be prepared to calculate file sizes and discuss the trade-offs between quality and storage.
未压缩单声道声音的文件大小 = 采样率 × 样本分辨率 × 时长。立体声则乘以2。奈奎斯特定理指出,采样频率必须至少是声音中最高频率的两倍,以避免混叠。在 CCEA 考试中,准备好计算文件大小并讨论质量与存储之间的权衡。
9. Data Compression: Lossy and Lossless | 数据压缩:有损与无损
Compression reduces the number of bits needed to store or transmit data. Lossless compression preserves the original data perfectly, using techniques like run-length encoding (RLE) and dictionary-based methods (LZW). RLE replaces consecutive identical values with a count and the value, e.g., ‘AAAAABBB’ becomes ‘5A3B’. It is effective for simple graphics with large uniform areas.
压缩可减少存储或传输数据所需的位数。无损压缩完美保留原始数据,使用游程编码(RLE)和基于字典的方法(LZW)等技术。RLE 将连续相同的值替换为计数值和值本身,例如 ‘AAAAABBB’ 变为 ‘5A3B’。对有大面积均匀区域的简单图形很有效。
Lossy compression permanently removes some data to achieve higher compression ratios, relying on the limitations of human perception (e.g., JPEG for photos, MP3 for audio). JPEG discards high-frequency colour variations; MP3 removes sounds outside typical hearing range or masked by louder sounds. CCEA expects you to explain the difference and justify choice of compression for given scenarios.
有损压缩会永久性删除部分数据以实现更高的压缩比,依赖人类感知的局限性(例如,照片使用 JPEG,音频使用 MP3)。JPEG 丢弃高频色彩变化;MP3 去除典型听觉范围之外或被更响声音掩盖的声音。CCEA 期望你解释差异,并针对给定场景论证压缩的选择。
10. Error Detection: Parity Bits and Checksums | 错误检测:奇偶校验位与校验和
During transmission or storage, data can become corrupted due to interference or hardware faults. Parity bits provide a simple error detection mechanism. In even parity, the sender adds a bit so that the total number of 1s in the byte is even; the receiver checks the parity. If a single bit flips, the parity will be wrong. However, parity cannot detect an even number of errors.
在传输或存储过程中,数据可能因干扰或硬件故障而损坏。奇偶校验位提供一种简单的错误检测机制。在偶校验中,发送方添加一个位,使得字节中1的总数为偶数;接收方检查奇偶性。如果有一位翻转,奇偶性就会出错。但奇偶校验无法检测偶数个错误。
Checksums involve adding up all the data bytes (ignoring overflow) and transmitting the result. The receiver recomputes the sum and compares. If the sums differ, an error has occurred. More advanced methods, such as cyclic redundancy checks (CRC), are used in network protocols. CCEA questions often ask you to calculate parity bits or determine if received data contains an error based on parity.
校验和涉及将所有数据字节相加(忽略溢出)并传输结果。接收方重新计算总和并比较。如果总和不同,则发生了错误。更先进的方法,如循环冗余校验(CRC),用于网络协议。CCEA 题目经常要求计算奇偶校验位,或根据奇偶性判断接收数据是否包含错误。
11. Binary Representation in Programming | 编程中的二进制表示
Understanding data representation is critical when writing programs that manipulate low-level data, use bitwise operators, or control hardware. CCEA programming tasks may involve masking bits, shifting, or converting between hex strings and numeric types. Bitwise AND, OR, XOR, and NOT operate at the individual bit level and are commonly used for flag testing, setting, and clearing.
在编写处理底层数据、使用位运算符或控制硬件的程序时,理解数据表示至关重要。CCEA 的编程任务可能涉及位掩码、移位或在十六进制字符串与数值类型之间转换。按位与、或、异或和非在单个位级别上操作,常用于标志位的测试、设置和清除。
A left shift by n places multiplies an unsigned binary number by 2^n, while a logical right shift divides by 2^n. An arithmetic right shift preserves the sign bit for two’s complement numbers. Example: 0000 1010 (10) shifted left by 1 → 0001 0100 (20). Be aware of potential overflow when shifting.
左移 n 位将无符号二进制数乘以 2^n,而逻辑右移则除以 2^n。算术右移保留二进制补码数的符号位。示例:0000 1010 (10) 左移1位 → 0001 0100 (20)。注意移位时可能发生溢出。
12. Exam Tips and Common Pitfalls | 考试技巧与常见陷阱
In CCEA data representation questions, always read the number of bits specified (e.g., 8-bit two’s complement, 12-bit floating point). Show all working, including bit groupings and division steps, to secure method marks. For compression and encoding, link your answer to the context: e.g., why JPEG is suitable for photographs but not for text.
在 CCEA 数据表示题目中,务必仔细阅读指定位数(例如 8位二进制补码,12位浮点数)。展示所有计算步骤,包括位分组和除法步骤,以获取方法分。对于压缩和编码,要将答案与上下文联系:例如,为什么 JPEG 适合照片但不适合文本。
A common mistake is confusing hexadecimal and binary when doing arithmetic. Another is forgetting to add the carry when computing two’s complement. Practise conversions under timed conditions. Remember that normalised floating point always has a mantissa starting with ‘0.1’ for positive numbers, or ‘1.0’ for negative numbers, depending on the representation convention used in your course.
一个常见错误是在进行算术运算时混淆十六进制和二进制。另一个错误是在计算二进制补码时忘记加进位。在限时条件下练习转换。记住,规范化的浮点数对于正数,尾数总是以 ‘0.1’ 开头,对于负数以 ‘1.0’ 开头,具体取决于课程使用的表示约定。
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课程辅导,国外大学本科硕士研究生博士课程论文辅导