📚 Data Representation in Cambridge IGCSE Computer Science | 剑桥IGCSE计算机科学中的数据表示
In the Cambridge IGCSE Computer Science syllabus (0478), data representation forms the bedrock of understanding how computers store and process information. This revision guide, closely aligned with the Complete Computer Science for Cambridge IGCSE & O Level Student Book, walks you through every essential topic from binary basics to compression.
在剑桥 IGCSE 计算机科学课程(0478)中,数据表示是理解计算机如何存储和处理信息的基石。这篇复习指南紧密结合《Complete Computer Science for Cambridge IGCSE & O Level Student Book》,带你走过从二进制基础到数据压缩的每一个核心主题。
1. Why Binary? | 为什么使用二进制?
All modern computers rely on binary because digital circuits can only recognise two stable states: ON (represented by 1) and OFF (represented by 0). This two-state system is highly reliable and minimises errors in data transmission and storage.
所有现代计算机都依赖二进制,因为数字电路只能识别两种稳定状态:开(用 1 表示)和关(用 0 表示)。这种双态系统高度可靠,能最大限度地减少数据传输和存储中的错误。
Binary is the universal language of digital devices. Numbers, characters, images and sounds are all encoded into sequences of bits (binary digits). A single bit is the smallest unit of data; a group of 8 bits is called a byte.
二进制是数字设备的通用语言。数字、字符、图像和声音都会被编码成比特(二进制位)序列。一个比特是最小的数据单位;8 个比特组成一个字节。
2. Binary, Denary and Hexadecimal | 二进制、十进制与十六进制
In IGCSE Computer Science you must be fluent in three number systems: binary (base‑2), denary (base‑10) and hexadecimal (base‑16). Denary uses digits 0–9; binary uses 0 and 1; hexadecimal uses 0–9 followed by A–F to represent values 10–15.
在 IGCSE 计算机科学中,你必须熟练掌握三种数制:二进制(基数为 2)、十进制(基数为 10)和十六进制(基数为 16)。十进制使用数字 0–9;二进制使用 0 和 1;十六进制使用 0–9 以及 A–F 来表示数值 10–15。
Hexadecimal is a shorthand for binary because one hex digit represents exactly four bits (a nibble). This makes it much easier for humans to read long binary strings, such as memory addresses or colour codes.
十六进制是二进制的简写形式,因为一个十六进制数位恰好代表四个比特(一个半字节)。这使得人们更容易阅读长二进制串,如内存地址或颜色代码。
| Denary | Binary (4‑bit) | Hexadecimal |
|---|---|---|
| 0 | 0000 | 0 |
| 7 | 0111 | 7 |
| 10 | 1010 | A |
| 15 | 1111 | F |
3. Converting Between Number Systems | 数制之间的转换
To convert a binary number to denary, multiply each bit by its place value (powers of 2) and add the results. For example, binary 1011 equals (1 × 2³) + (0 × 2²) + (1 × 2¹) + (1 × 2⁰) = 8 + 0 + 2 + 1 = 11 in denary.
要将二进制数转换为十进制,将每一位乘以其位值(2 的幂)并求和。例如,二进制 1011 等于 (1 × 2³) + (0 × 2²) + (1 × 2¹) + (1 × 2⁰) = 8 + 0 + 2 + 1 = 11(十进制)。
For denary to binary, repeatedly divide the number by 2 and record the remainders; read the remainders backwards to obtain the binary equivalent. Converting hexadecimal to binary simply requires replacing each hex digit with a 4‑bit binary group.
十进制转二进制时,反复将数字除以 2 并记录余数;反向读出余数即可得到对应的二进制数。将十六进制转换为二进制只需将每个十六进制数位替换成一个 4 比特的二进制组。
When converting binary to hexadecimal, split the binary number into groups of four bits starting from the right, then convert each group to its hex equivalent.
将二进制转换为十六进制时,从右向左每四位比特划分为一组,然后将每组转换为相应的十六进制数位。
4. Binary Addition and Overflow | 二进制加法与溢出
Binary addition follows simple rules: 0+0=0, 0+1=1, 1+0=1, and 1+1=0 with a carry of 1 to the next column. The process is identical to denary addition but limited to two digits.
二进制加法遵循简单规则:0+0=0,0+1=1,1+0=1,1+1=0 并向下一列进位 1。该过程与十进制加法相同,但只限于两个数字。
Overflow occurs when the sum of two binary numbers exceeds the maximum value that can be stored in the allocated number of bits. In an 8‑bit system, an overflow flag is set if the result falls outside the range of −128 to 127 (in two’s complement) or 0 to 255 (unsigned).
当两个二进制数的和超出指定比特数所能存储的最大值时,会产生溢出。在 8 位系统中,如果结果超出 −128 至 127 范围(补码表示)或 0 至 255(无符号),溢出标志会被置位。
You must be able to distinguish between a carry‑out and an overflow. A carry‑out beyond the most significant bit is normal for unsigned arithmetic, but overflow indicates a sign error in signed arithmetic.
你必须能够区分进位输出和溢出。对于无符号运算,超出最高有效位的进位是正常的,但溢出表明在有符号运算中出现了符号错误。
5. Two’s Complement Representation | 二进制补码表示法
Two’s complement is the standard method for representing signed integers in binary. To obtain the two’s complement of a negative number, invert all bits of its positive counterpart and add 1 to the least significant bit.
二进制补码是表示有符号整数的标准方法。要获得一个负数的补码,先将其绝对值的所有比特取反,然后在最低有效位上加 1。
For an 8‑bit register, two’s complement provides a range from −128 to +127. The most significant bit indicates the sign (0 = positive, 1 = negative), and the same addition circuit can handle both positive and negative numbers without modification.
对于 8 位寄存器,补码的表示范围为 −128 至 +127。最高有效位指示符号(0 表示正数,1 表示负数),并且同一加法电路无需改动即可同时处理正负数。
Example: −6 in 8‑bit two’s complement → positive 6 = 0000 0110 → invert → 1111 1001 → add 1 → 1111 1010
示例:−6 的 8 位补码 → 正 6 = 0000 0110 → 取反 → 1111 1001 → 加 1 → 1111 1010
6. Logical Shifts | 逻辑移位
A logical left shift moves every bit one place to the left; the left‑most bit is lost and a 0 enters the right‑most position. Each left shift multiplies the binary number by 2 (filling with zeros on the right) and can cause overflow if a 1 is shifted out.
逻辑左移将每一位向左移动一个位置;最左边的比特丢失,最右边移入 0。每次左移都会将二进制数乘以 2(右侧补零),如果有 1 被移出则可能引发溢出。
A logical right shift moves all bits to the right, copying a 0 into the left‑most empty position. Each right shift divides the number by 2, ignoring any remainder. This operation is used for fast integer division by powers of two.
逻辑右移将所有比特向右移动,最左侧空出的位置补入 0。每次右移将数字除以 2 并忽略余数。此操作用于快速实现整数除以 2 的幂次。
IGCSE questions will often ask you to predict the result of a shift operation or to explain how shifts can be used for multiplication and division. Always state the effect on the binary value and the risk of losing data.
IGCSE 考题经常要求你预测移位操作的结果,或解释如何用移位进行乘除运算。一定要说明对二进制数值的影响以及丢失数据的风险。
7. Representing Text | 文本的表示
Characters are stored as numeric codes. The ASCII (American Standard Code for Information Interchange) system originally used 7 bits, encoding 128 characters including letters, digits and control codes. Extended ASCII uses 8 bits to cover 256 characters, adding accented letters and symbols.
字符以数字代码存储。ASCII(美国信息交换标准代码)系统最初使用 7 比特,编码了包括字母、数字和控制码在内的 128 个字符。扩展 ASCII 使用 8 比特,涵盖 256 个字符,增加了带重音符号的字母和符号。
Unicode was developed to support a much wider range of characters from different writing systems. UTF‑8, a popular Unicode encoding, is backward‑compatible with ASCII and uses a variable number of bytes per character. This allows global communication without loss of data.
Unicode 的开发是为了支持来自不同书写系统的更广泛的字符集。流行的 Unicode 编码 UTF‑8 与 ASCII 向后兼容,每个字符使用可变数量的字节。这使得全球通信成为可能而不会丢失数据。
8. Representing Images | 图像的表示
Bitmap images are made of a grid of tiny squares called pixels. Each pixel’s colour is stored as a binary value. The colour depth (measured in bits per pixel) controls how many distinct colours can be represented. For example, an 8‑bit colour depth allows 2⁸ = 256 colours.
位图图像由称为像素的微小方格网格构成。每个像素的颜色存储为二进制值。颜色深度(以每像素位数衡量)决定可以表示多少种不同的颜色。例如,8 位颜色深度允许 2⁸ = 256 种颜色。
Resolution is the number of pixels in the image, usually expressed as width × height. The file size (in bits) of an uncompressed bitmap can be calculated with the formula:
分辨率指图像中的像素数量,通常表示为宽 × 高。未压缩位图的文件大小(比特)可用以下公式计算:
File size = width × height × colour depth
文件大小 = 宽度 × 高度 × 颜色深度
Higher resolution or colour depth improves image quality but demands more storage space and longer transmission times.
更高的分辨率或颜色深度能改善画质,但需要更多的存储空间和更长的传输时间。
9. Representing Sound | 声音的表示
Sound is an analogue wave that must be converted into digital form by sampling. The sampling rate (measured in hertz) is the number of samples taken per second. According to the Nyquist theorem, the sampling rate must be at least twice the highest frequency in the sound to reproduce it accurately.
声音是一种模拟波,必须通过采样转换为数字形式。采样率(以赫兹计)是每秒采集的样本数。根据奈奎斯特定理,采样率必须至少为声音中最高频率的两倍才能精确再现。
Bit depth defines how many bits are used to store each sample. A higher bit depth allows finer gradations of amplitude, improving dynamic range. The file size of uncompressed audio is calculated as:
位深度定义了存储每个样本所使用的比特数。更高的位深度允许更精细的振幅分级,从而改善动态范围。未压缩音频的文件大小计算公式为:
File size = sampling rate × bit depth × duration (seconds) × number of channels
文件大小 = 采样率 × 位深度 × 时长(秒) × 声道数
For example, a 10‑second stereo track sampled at 44.1 kHz with 16‑bit depth requires approximately 44,100 × 16 × 10 × 2 = 14,112,000 bits, or about 1.68 MB.
例如,一段 10 秒长的立体声曲目,以 44.1 kHz 采样、16 位深度录制,大约需要 44,100 × 16 × 10 × 2 = 14,112,000 比特,约 1.68 MB。
10. Data Compression and File Sizes | 数据压缩与文件大小
Compression reduces the number of bits required to store or transmit data, saving storage space and bandwidth. It is essential for large files such as high‑resolution images, videos and music.
压缩可减少存储或传输数据所需的比特数,从而节省存储空间和带宽。这对于高分辨率图像、视频和音乐等大型文件至关重要。
Lossless compression removes redundancy without losing any original data; the original file can be perfectly reconstructed. Run‑length encoding (RLE) is a simple lossless method where repeated data values are stored as a single value and a count.
无损压缩去除冗余而不丢失任何原始数据;原始文件可以被完美地重建。游程编码(RLE)是一种简单的无损方法,将重复的数据值存储为一个值和计数值。
Lossy compression permanently discards some data that is considered less noticeable to human senses. JPEG for images and MP3 for audio are common examples. IGCSE students must be able to compare the advantages and drawbacks of both methods.
有损压缩永久性地丢弃一些对人类感官来说不易察觉的数据。图像的 JPEG 和音频的 MP3 是常见的例子。IGCSE 学生必须能够比较两种方法的优缺点。
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课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply