📚 IGCSE Computer Science: Data Representation Key Points | IGCSE 计算机:数据表示 考点精讲
In IGCSE Computer Science, understanding how data is represented inside a computer is essential. This topic explains why computers use binary, how numbers, text, images and sound are encoded, and how file sizes and compression work. Mastering these concepts will help you answer both theory and calculation questions accurately in the exam.
在 IGCSE 计算机科学中,理解数据在计算机内部的表示方式至关重要。本主题解释了计算机为什么使用二进制,数字、文本、图像和声音如何编码,以及文件大小和压缩的原理。掌握这些概念能帮助你在考试中准确回答理论和计算题。
1. Binary System | 二进制系统
Computers use the binary number system because they are built from billions of switches that can only be in one of two states: on (1) or off (0). Each binary digit is called a ‘bit’. A group of 8 bits is called a byte. The place values in an 8-bit binary number are 2⁷, 2⁶, 2⁵, 2⁴, 2³, 2², 2¹ and 2⁰ (128, 64, 32, 16, 8, 4, 2, 1).
计算机使用二进制数制,因为它们由数十亿个只能处于两种状态之一的开关构成:开(1)或关(0)。每个二进制数字称为一个“位”(bit)。一组 8 位称为一个字节。8 位二进制数的位权值分别为 2⁷, 2⁶, 2⁵, 2⁴, 2³, 2², 2¹ 和 2⁰(128, 64, 32, 16, 8, 4, 2, 1)。
To convert a binary number to denary, multiply each bit by its place value and sum the results. For example, the binary number 01101001₂ is calculated as (0×128) + (1×64) + (1×32) + (0×16) + (1×8) + (0×4) + (0×2) + (1×1) = 105 in denary.
将二进制数转换为十进制时,将每一位乘以其位权值再相加。例如,二进制数 01101001₂ 的计算为 (0×128) + (1×64) + (1×32) + (0×16) + (1×8) + (0×4) + (0×2) + (1×1) = 105(十进制)。
2. Hexadecimal System | 十六进制系统
Hexadecimal (base 16) is a compact way to represent binary values. It uses digits 0–9 and letters A–F, where A=10, B=11, C=12, D=13, E=14, F=15. One hex digit represents exactly four binary bits (a nibble), so 8-bit binary can be written as two hex digits. This makes it much easier for humans to read and debug machine code, colour codes and memory addresses.
十六进制(基数为 16)是一种表示二进制值的紧凑方式。它使用数字 0–9 和字母 A–F,其中 A=10, B=11, C=12, D=13, E=14, F=15。一位十六进制数字恰好表示四位二进制位(一个半字节),因此 8 位二进制可写成两位十六进制数字。这使人们更容易阅读和调试机器码、颜色代码和内存地址。
For instance, the binary 1011 1100₂ becomes BC₁₆ because 1011₂ = 11 (B) and 1100₂ = 12 (C). Hexadecimal numbers are often prefixed with ‘0x’ or followed by an ‘H’ in computing contexts.
例如,二进制 1011 1100₂ 变为 BC₁₆,因为 1011₂ = 11(B),1100₂ = 12(C)。在计算领域中,十六进制数常带有前缀“0x”或后缀“H”。
3. Converting Between Binary and Denary | 二进制与十进制转换
To convert denary to binary, repeatedly divide the denary number by 2 and record the remainders, then read the remainders backwards. Alternatively, use the place-value method: subtract the largest possible power of 2 that does not exceed the number, write a 1 in that place, and continue with the remainder. For example, 78₁₀ = 64 + 8 + 4 + 2, giving binary 01001110₂ (in 8 bits).
将十进制转换为二进制时,反复将十进制数除以 2 并记录余数,然后逆序读取余数。另一种方法是使用位权值法:减去不超过该数的最大 2 的幂,在该位写 1,然后对余数继续操作。例如,78₁₀ = 64 + 8 + 4 + 2,得到 8 位二进制 01001110₂。
Always ensure you know the required number of bits; in IGCSE questions you will often be asked to use 8-bit representation. If the number is too large to fit in 8 bits, an overflow error occurs.
务必注意题目要求的位数;在 IGCSE 题目中经常会要求使用 8 位表示。如果数字过大无法放入 8 位,就会发生溢出错误。
4. Converting Between Hexadecimal and Denary/Binary | 十六进制与十进制/二进制转换
To convert hex to denary, multiply each hex digit by the corresponding power of 16 (rightmost digit is 16⁰, then 16¹, 16², etc.) and sum the results. For 2F₁₆: (2×16) + (15×1) = 32 + 15 = 47₁₀. Converting hex to binary is even simpler: replace each hex digit with its 4-bit binary equivalent. 5A₁₆ becomes 0101 1010₂.
要将十六进制转换为十进制,将每位十六进制数字乘以对应的 16 的幂(最右边为 16⁰,然后是 16¹, 16² 等)并相加。对于 2F₁₆:(2×16) + (15×1) = 32 + 15 = 47₁₀。将十六进制转换为二进制更简单:将每位十六进制数字替换为其 4 位二进制等值。5A₁₆ 变为 0101 1010₂。
When converting denary to hex, you can either convert the denary number to binary first and then group into nibbles, or repeatedly divide the denary number by 16, noting the remainder as a hex digit.
当将十进制转换为十六进制时,你可以先将十进制数转换为二进制,再分组为半字节;或者反复将十进制数除以 16,将余数记作十六进制数字。
5. Binary Addition and Overflow | 二进制加法与溢出
Binary addition follows the same rules as denary addition but with only two digits. The four basic sums are: 0+0=0, 0+1=1, 1+0=1, and 1+1=0 with a carry of 1 to the next column. When the result exceeds the maximum value that can be stored in the given number of bits (e.g. 255 for 8 bits), an overflow error occurs. The computer detects this and may store an overflow flag.
二进制加法遵循与十进制加法相同的规则,但只有两个数字。四种基本加法为:0+0=0,0+1=1,1+0=1,1+1=0 并向下一列进 1。当结果超出给定位数所能存储的最大值(例如 8 位最大值为 255)时,就会发生溢出错误。计算机检测到此情况并可能存储一个溢出标志。
Example: adding 10010110₂ (150) and 10011001₂ (153) in 8 bits gives 1 00101111₂ with an extra carry beyond the MSB. The 9-bit result shows overflow; only the lower 8 bits are kept, which produces an incorrect value.
示例:将 8 位的 10010110₂(150)和 10011001₂(153)相加,得到 1 00101111₂,在最高位之外多出一个进位。9 位结果表示溢出;仅保留低 8 位会产生错误的值。
6. Character Encoding – ASCII and Unicode | 字符编码 – ASCII 与 Unicode
Characters are stored in the computer as binary codes. The most basic system is ASCII (American Standard Code for Information Interchange), which uses 7 bits to represent 128 characters, including letters, digits and punctuation. Extended ASCII uses 8 bits (1 byte) to represent 256 characters, adding some accented and graphical characters.
字符在计算机中以二进制代码的形式存储。最基本的系统是 ASCII(美国信息交换标准代码),它使用 7 位来表示 128 个字符,包括字母、数字和标点符号。扩展 ASCII 使用 8 位(1 字节)来表示 256 个字符,增加了一些带重音符号和图形字符。
However, encoding all the world’s writing systems requires a larger character set. Unicode was developed to solve this. It can represent over 143,000 characters using variable numbers of bits. UTF-8, a common Unicode encoding, is backward compatible with ASCII. In exams, you may be asked why Unicode is needed rather than ASCII, or to compare their features.
然而,要编码世界上所有的书写系统需要更大的字符集。Unicode 应运而生。它可以使用可变位数来表示超过 143,000 个字符。常见的 Unicode 编码 UTF-8 向后兼容 ASCII。在考试中,你可能会被问到为什么需要 Unicode 而不是 ASCII,或者比较它们的特点。
7. Representing Images | 图像表示
Digital images are stored as bitmaps, which are grids of tiny squares called pixels (picture elements). Each pixel is assigned a binary value representing its colour. The colour depth (or bit depth) indicates how many bits are used per pixel. A higher colour depth allows more colours to be represented. For example, 1 bit per pixel gives 2 colours (black and white); 8 bits per pixel give 256 colours; 24 bits per pixel give over 16 million colours (true colour).
数字图像以位图形式存储,位图是由称为像素的小方格组成的网格。每个像素都被赋予一个表示其颜色的二进制值。颜色深度(或位深度)表示每个像素使用多少位。颜色深度越高,能表示的颜色越多。例如,每像素 1 位可产生 2 种颜色(黑白);每像素 8 位可产生 256 种颜色;每像素 24 位可产生超过 1600 万种颜色(真彩色)。
The number of pixels in the image (its resolution) is usually given as width × height, e.g. 1920 × 1080. Together with colour depth, this determines the raw file size. A higher resolution gives sharper images but larger file sizes.
图像中的像素数量(即其分辨率)通常表示为宽×高,例如 1920 × 1080。它与颜色深度一起决定了原始文件大小。分辨率越高,图像越清晰,但文件也越大。
8. Calculating Image File Size | 图像文件大小计算
The uncompressed file size of a bitmap image can be calculated using the formula:
Image file size (bits) = width (pixels) × height (pixels) × colour depth (bits per pixel)
可以使用以下公式计算位图图像的未压缩文件大小:
图像文件大小(位)= 宽(像素) × 高(像素) × 颜色深度(每像素位数)
To convert bits to bytes, divide by 8. To convert bytes to kilobytes, divide by 1024 (or 1000 depending on the context; IGCSE usually accepts 1024 for Kibibytes or may specify). For example, a 1000 × 800 pixel image with 16-bit colour depth: size = 1000 × 800 × 16 = 12,800,000 bits = 1,600,000 bytes ≈ 1.53 MiB.
要将位转换为字节,请除以 8。要将字节转换为千字节,除以 1024(或根据上下文使用 1000;IGCSE 通常接受 1024 表示千字节或可能会明确说明)。例如,一张 1000 × 800 像素、16 位颜色深度的图像:大小 = 1000 × 800 × 16 = 12,800,000 位 = 1,600,000 字节 ≈ 1.53 MiB。
Note that this is the size of the raw image data; actual file sizes may be smaller if compression is used.
请注意,这是原始图像数据的大小;如果使用压缩,实际文件大小可能会更小。
9. Representing Sound | 声音表示
Sound is an analogue wave and must be converted into digital form to be stored in a computer. This is done by an analogue-to-digital converter (ADC) that takes measurements (samples) of the amplitude of the wave at regular intervals. The sampling rate (measured in Hz) is how many samples are taken per second; a higher sampling rate captures higher frequencies and gives better sound quality.
声音是模拟波,必须转换为数字形式才能在计算机中存储。这由模数转换器(ADC)完成,它以固定的时间间隔对波的振幅进行测量(采样)。采样率(以赫兹计)是每秒采样的次数;采样率越高,能捕获的频率越高,音质越好。
The sampling resolution (bit depth) is the number of bits used to store each sample. A higher bit depth allows more accurate representation of the amplitude. Common values are 8-bit or 16-bit. Stereo sound uses two channels (left and right), which doubles the amount of data compared to mono.
采样分辨率(位深度)是用于存储每个样本的位数。位深度越高,振幅的表示越精确。常见的值为 8 位或 16 位。立体声使用两个声道(左右),与单声道相比数据量翻倍。
10. Calculating Sound File Size | 声音文件大小计算
The uncompressed file size of a digital audio recording can be found with:
Sound file size (bits) = sampling rate (Hz) × bit depth (bits) × number of channels × duration (seconds)
数字音频录音的未压缩文件大小可以用以下公式计算:
声音文件大小(位)= 采样率(Hz) × 位深度(位) × 声道数 × 时长(秒)
For example, a 3-minute stereo recording with 44,100 Hz sampling rate and 16-bit resolution: size = 44,100 × 16 × 2 × 180 = 253,056,000 bits = 31,632,000 bytes ≈ 30.2 MiB. Remember to convert minutes to seconds first. Also note that audio CD quality uses 44,100 Hz and 16-bit stereo.
例如,一段 3 分钟立体声录音,采样率 44,100 Hz,分辨率 16 位:大小 = 44,100 × 16 × 2 × 180 = 253,056,000 位 = 31,632,000 字节 ≈ 30.2 MiB。记得先将分钟转换为秒。另外请注意,CD 音质采用 44,100 Hz 和 16 位立体声。
11. Data Compression | 数据压缩
Compression reduces file size, making storage and transmission more efficient. There are two main types: lossy and lossless. Lossy compression permanently removes some data to achieve smaller files, and is used where a perfect reproduction is not critical – e.g. JPEG for images, MP3 for audio. Lossless compression temporarily removes redundancy and can reconstruct the original file exactly; it is used for text, program files and archival storage – e.g. ZIP, PNG, FLAC.
压缩可减小文件大小,使存储和传输更高效。主要有两种类型:有损和无损。有损压缩会永久删除部分数据以获得更小的文件,用于不需要完全还原的场合——例如图像的 JPEG、音频的 MP3。无损压缩会暂时去除冗余,并能精确重建原始文件;用于文本、程序文件和存档——例如 ZIP、PNG、FLAC。
Common compression methods include Run Length Encoding (RLE), which replaces repeated characters with a count and character, and dictionary-based algorithms like Huffman coding. IGCSE often asks about the principle and applications of lossy versus lossless compression.
常见的压缩方法包括游程编码(RLE),它用一个计数和字符来替代重复的字符;还有基于字典的算法,如哈夫曼编码。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课程辅导,国外大学本科硕士研究生博士课程论文辅导