📚 GCSE Computer Science: Data Representation Essentials | GCSE 计算机:数据表示 考点精讲
Data representation is the foundation of all digital systems, explaining how text, numbers, images, and sound are stored as binary. In GCSE Computer Science, you must master binary and hexadecimal conversions, binary arithmetic, storage units, character encoding, and the calculation of file sizes for images and sound. This revision guide covers every key concept, with worked examples and comparison tables to help you prepare for your exam.
数据表示是所有数字系统的基础,解释了文本、数字、图像和声音如何以二进制形式存储。在 GCSE 计算机科学中,你必须掌握二进制与十六进制的转换、二进制运算、存储单位、字符编码以及图像和声音文件大小的计算。这份考点精讲涵盖了所有关键概念,并配有详解示例和对比表格,助你高效备考。
1. Why Binary and Other Number Systems | 为什么使用二进制与其他数制
Computers use binary (base-2) because digital circuits can only represent two states: on (1) and off (0). Every piece of data, from a simple character to a high-resolution video, is ultimately stored as a sequence of 0s and 1s. While binary is perfect for machines, it is cumbersome for humans. This is why we also study decimal (base-10) for our daily lives and hexadecimal (base-16) as a shorthand for binary.
计算机使用二进制(基数为 2),因为数字电路只能表示两种状态:开(1)和关(0)。从简单的字符到高分辨率视频,每一份数据最终都存储为一串 0 和 1。尽管二进制对机器而言十分理想,但对人类来说却十分冗长。因此我们也会学习日常使用的十进制(基数为 10)以及作为二进制简写形式的十六进制(基数为 16)。
The place values in binary are powers of 2 (128, 64, 32, 16, 8, 4, 2, 1 for an 8-bit number). Understanding place value is essential for accurate conversion between number systems.
二进制的位值是 2 的幂(对 8 位数字而言为 128、64、32、16、8、4、2、1)。理解位值是在不同数制之间准确转换的基础。
2. Binary to Denary Conversion | 二进制转十进制
To convert a binary number to decimal, write the binary digits under the correct place values and add up the values wherever a 1 appears. For example, the 8-bit binary number 10110101 corresponds to 128 + 0 + 32 + 16 + 0 + 4 + 0 + 1 = 181 in decimal.
要将二进制数转换为十进制,只需将二进制数字写在对应的位值下方,然后将所有出现 1 的位值相加。例如,8 位二进制数 10110101 对应 128 + 0 + 32 + 16 + 0 + 4 + 0 + 1 = 181(十进制)。
| Place value / 位值 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| Binary / 二进制 | 1 | 0 | 1 | 1 | 0 | 1 | 0 | 1 |
This method works for any number of bits. For negative numbers, exams may use two’s complement, but standard conversion remains the same for unsigned binary.
该方法适用于任意位数的二进制数。对于负数,考试可能使用二进制补码,但无符号二进制的标准转换方式不变。
3. Denary to Binary Conversion | 十进制转二进制
The most common exam method is repeated division by 2. Write the decimal number, repeatedly divide by 2, recording the remainder (0 or 1) each time, and read the remainders from bottom to top. For example, converting 181 to binary gives 10110101.
最常见的考试方法是重复除以 2。写出十进制数,不断除以 2,每次记录余数(0 或 1),然后从下往上读取余数。例如,181 转换为二进制得到 10110101。
181 ÷ 2 = 90 remainder 1
90 ÷ 2 = 45 remainder 0
45 ÷ 2 = 22 remainder 1
22 ÷ 2 = 11 remainder 0
11 ÷ 2 = 5 remainder 1
5 ÷ 2 = 2 remainder 1
2 ÷ 2 = 1 remainder 0
1 ÷ 2 = 0 remainder 1
An alternative method is to subtract the largest possible power of 2 until zero is reached. Both approaches require practice to gain speed in exams.
另一种方法是从十进制中不断减去可能的最大 2 次幂,直至归零。这两种方法都需要多加练习,才能在考试中提升速度。
4. Binary Addition and Overflow | 二进制加法与溢出
Binary addition follows simple rules: 0+0=0, 1+0=1, 1+1=0 carry 1, and 1+1+1=1 carry 1. When adding two 8-bit numbers, if the result requires a 9th bit, an overflow error occurs because the register cannot store it. Computer systems can detect overflow using a status flag.
二进制加法遵循简单规则:0+0=0,1+0=1,1+1=0 进位 1,以及 1+1+1=1 进位 1。当两个 8 位数字相加时,如果结果需要第 9 位,由于寄存器无法存储,就会发生溢出错误。计算机系统可以使用状态标志来检测溢出。
Example: Adding 10101100 (172) and 01110101 (117) gives 1 00100001, which is 289 but the leftmost 1 is lost in an 8-bit register, leaving 00100001 (33). This incorrect result demonstrates overflow.
示例:将 10101100(172)与 01110101(117)相加,得到 1 00100001,即 289,但在 8 位寄存器中,最左边的 1 会丢失,仅剩 00100001(33)。这一错误结果说明了溢出的发生。
Overflow is a key reason why programmers must choose appropriate data types (e.g., 16-bit or 32-bit integers) to avoid unexpected behaviour.
溢出是程序员必须选择合适数据类型(如 16 位或 32 位整数)以避免意外行为的关键原因。
5. The Hexadecimal System | 十六进制系统
Hexadecimal (base-16) uses digits 0–9 and letters A–F to represent values 0–15. It is widely used in computing because one hex digit maps exactly to four binary bits (a nibble). This makes reading and writing long binary strings much easier for programmers, especially in memory addresses and colour codes.
十六进制(基数为 16)使用数字 0–9 和字母 A–F 表示数值 0–15。由于每个十六进制数字恰好对应四个二进制位(一个半字节),它在计算领域得到广泛应用。这样一来,程序员可以轻松读写冗长的二进制串,特别是在内存地址和颜色代码中。
| Denary / 十进制 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Hex / 十六进制 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
6. Conversions Involving Hexadecimal | 十六进制相关转换
Converting binary to hex is straightforward: split the binary number into groups of four bits (from the right), then replace each group with its hex equivalent. For instance, 10110101 becomes 1011 0101, which is B and 5, giving hexadecimal B5.
二进制转十六进制非常简单:将二进制数字从右向左每四位一组分开,然后将每组替换为对应的十六进制值。例如,10110101 分为 1011 和 0101,分别对应 B 和 5,得到十六进制 B5。
To convert hex to denary, multiply each hex digit by its place value (powers of 16). B5 in hex = B(16) × 16⁰ + 5 × 16⁰? Wait careful: B5 means B in the 16s place and 5 in the 1s place. So B5 = (11 × 16) + (5 × 1) = 176 + 5 = 181. Alternatively, convert hex to binary first, then binary to denary.
将十六进制转换为十进制时,将每一位十六进制数字乘以其位值(16 的幂)。B5 中的 B 在 16 位,5 在个位。因此 B5 = (11 × 16) + (5 × 1) = 176 + 5 = 181。也可以先将十六进制转为二进制,再将二进制转为十进制。
GCSE exams frequently ask you to demonstrate all three conversions: binary ↔ denary, binary ↔ hex, and hex ↔ denary.
GCSE 考试经常要求你展示全部三种转换:二进制 ↔ 十进制、二进制 ↔ 十六进制,以及十六进制 ↔ 十进制。
7. Bits, Bytes, and Units of Storage | 位、字节与存储单位
Bit: The smallest unit of data, a single 0 or 1.
位(Bit):数据的最小单位,一个 0 或 1。
Nibble: A group of 4 bits, useful for representing a single hex digit.
半字节(Nibble):一组 4 位,可方便地表示一个十六进制数字。
Byte: A group of 8 bits, the standard unit for storing a character or a small number. Most file sizes are expressed in bytes or its multiples.
字节(Byte):一组 8 位,是存储一个字符或一个小数字的标准单位。大多数文件大小都以字节或其倍数表示。
| Unit / 单位 | Equivalent in bytes (approx.) / 相当的字节数(近似) |
|---|---|
| Kilobyte (kB) / 千字节 | 1000 bytes or 10³ |
| Megabyte (MB) / 兆字节 | 1000 kB or 10⁶ bytes |
| Gigabyte (GB) / 吉字节 | 1000 MB or 10⁹ bytes |
| Terabyte (TB) / 太字节 | 1000 GB or 10¹² bytes |
Note that some computer systems use binary prefixes (kibibyte, mebibyte) based on powers of 2, but GCSE often uses the decimal definitions above unless specified otherwise.
注意,有些计算机系统使用基于 2 次幂的二进制前缀(kibibyte、mebibyte),但 GCSE 除非特别说明,一般使用上述十进制定义。
8. Character Encoding: ASCII and Unicode | 字符编码:ASCII 与 Unicode
Computers store characters by assigning a unique binary number to each symbol. The most basic system is ASCII, which uses 7 bits to represent 128 characters, including English letters, digits, and punctuation. Extended ASCII uses 8 bits and can represent 256 characters, adding special symbols and accented letters for Western European languages.
计算机通过为每个符号分配唯一的二进制数来存储字符。最基本的系统是 ASCII,它使用 7 位来表示 128 个字符,包括英文字母、数字和标点符号。扩展 ASCII 使用 8 位,可以表示 256 个字符,添加了西欧语言所需的特殊符号和重音字母。
Unicode was developed to support global writing systems and emojis. The most common encoding is UTF-8, which uses a variable number of bytes (1 to 4) per character. This allows it to be backward compatible with ASCII while covering thousands of characters from different languages.
Unicode 的开发旨在支持全球书写体系和表情符号。最常见的编码是 UTF-8,每个字符使用 1 到 4 个字节的可变长度。这使得它与 ASCII 向后兼容,同时涵盖了来自不同语言的成千上万个字符。
- ASCII: Simple, smaller file size, but limited to English.
- ASCII:简单,文件体积较小,但仅限于英语。
- Unicode: Comprehensive, supports virtually all scripts, but requires more storage per character in some cases.
- Unicode:全面,几乎支持所有文字,但在某些情况下每个字符需要更多存储空间。
9. Representing Images | 图像表示
A bitmap image is composed of a grid of pixels, each assigned a binary value representing its colour. The number of bits used for each pixel is called the colour depth. With a depth of 1 bit, you can only have two colours (black and white); with 8 bits, you get 256 possible colours; and with 24 bits (8 bits each for red, green, and blue), you can display over 16 million colours (2²⁴ = 16,777,216).
位图图像由像素网格组成,每个像素被分配一个表示其颜色的二进制值。为每个像素使用的位数称为颜色深度。颜色深度为 1 位时,只能显示两种颜色(黑和白);8 位可呈现 256 种颜色;而 24 位(红、绿、蓝各 8 位)则可显示超过 1600 万种颜色(2²⁴ = 16,777,216)。
The more pixels and the higher the colour depth, the better the image quality, but the larger the file size. The metadata (width, height, colour depth) is stored alongside the pixel data.
像素越多、颜色深度越高,图像质量越好,但文件体积也越大。元数据(宽度、高度、颜色深度)与像素数据一同存储。
Image file size (bits) = image width (pixels) × image height (pixels) × colour depth (bits per pixel)
图像文件大小(位)= 图像宽度(像素) × 图像高度(像素) × 颜色深度(每像素位数)
For a 100×100 pixel image with 24-bit colour depth, the size in bits is 100 × 100 × 24 = 240,000 bits, which is 240,000 / 8 = 30,000 bytes (approx. 30 kB).
对于一个 100×100 像素、24 位颜色深度的图像,以位为单位的大小为 100 × 100 × 24 = 240,000 位,即 240,000 ÷ 8 = 30,000 字节(约 30 kB)。
10. Representing Sound | 声音表示
Sound is analogue by nature, so to store it digitally we sample the amplitude of the sound wave at regular intervals. The sample rate (measured in hertz, Hz) indicates how many samples are taken per second. Common rates are 44.1 kHz for CD quality and 48 kHz for digital video. The bit depth determines the number of possible amplitude values (e.g., 16 bits allow 65,536 levels).
声音本质上是模拟信号,因此要以数字形式存储,我们需要等间隔地对声波的振幅进行采样。采样率(以赫兹 Hz 为单位)表示每秒采集的样本数。常见的采样率有 CD 音质的 44.1 kHz 和数字视频的 48 kHz。位深度决定可能的振幅值数量(例如,16 位允许 65,536 个级别)。
Higher sample rate and bit depth capture more detail and produce clearer sound, but they also increase the file size drastically. Mono sound uses one channel, while stereo uses two (left and right).
较高的采样率和位深度能够捕获更多细节,产生更清晰的声音,但也显著增加文件大小。单声道使用一个通道,而立體声使用两个通道(左和右)。
Sound file size (bits) = sample rate (Hz) × bit depth × duration (seconds) × number of channels
声音文件大小(位)= 采样率(Hz) × 位深度 × 时长(秒) × 声道数
A 30-second mono recording at 44.1 kHz with 16-bit depth: 44,100 × 16 × 30 × 1 = 21,168,000 bits = 2,646,000 bytes ≈ 2.65 MB.
一段 30 秒的单声道录音,采用 44.1 kHz 采样率和 16 位深度:44,100 × 16 × 30 × 1 = 21,168,000 位 = 2,646,000 字节 ≈ 2.65 MB。
11. Data Compression: Lossy vs Lossless | 数据压缩:有损与无损
Compression reduces file size to save storage space and speed up transmission. There are two main types you must know for GCSE.
压缩可减小文件体积,以节省存储空间并加快传输速度。GCSE 要求掌握两种主要类型。
Lossless compression reduces file size without losing any original data. When decompressed, the file is identical to the original. Run-length encoding (RLE) is a simple example: a sequence like ‘BBBBBBB’ might be stored as ‘7B’. Lossless is essential for text, executable files, and some image formats like PNG.
无损压缩在减小文件体积的同时不丢失任何原始数据。解压后,文件与原始文件完全相同。游程编码(RLE)是一个简单的例子:序列 ‘BBBBBBB’ 可能被存储为 ‘7B’。无损压缩对于文本文件、可执行文件以及某些图像格式(如 PNG)至关重要。
Lossy compression permanently removes data that is considered less noticeable to humans, such as very high sound frequencies in MP3 or subtle colour variations in JPEG images. The original file cannot be perfectly reconstructed, but a significant reduction in file size is achieved. It is suitable for photos, music, and video streaming where perfect accuracy is not required.
有损压缩会永久性地移除那些被认为不易被人察觉的数据,例如 MP3 中极高的声音频率,或 JPEG 图像中细微的颜色变化。尽管原始文件无法被完美重建,但可以显著减小文件大小。有损压缩适用于对精确度要求不高的照片、音乐和视频流。
| Feature / 特点 | Lossless / 无损 | Lossy / 有损 |
|---|---|---|
| Data integrity / 数据完整性 | All data preserved / 保留全部数据 | Some data lost / 部分数据丢失 |
| Compression ratio / 压缩比 | Moderate / 中等 | Very high / 很高 |
| Typical use / 典型用途 | Documents, PNG, ZIP / 文档、PNG、ZIP | JPEG, MP3, streaming / JPEG、MP3、流媒体 |
| Reversibility / 可逆性 | Fully reversible / 完全可逆 | Irreversible / 不可逆 |
Published by TutorHao | Data Representation Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导