IB AQA Computer Science: Data Representation Key Points | IB AQA 计算机:数据表示 考点精讲

📚 IB AQA Computer Science: Data Representation Key Points | IB AQA 计算机:数据表示 考点精讲

In computer science, data is represented using binary digits (bits) and higher‐level encodings that allow text, images, sound, and numbers to be stored and processed by digital systems. Mastering data representation is essential for the IB and AQA Computer Science examinations, as it underpins everything from memory addressing to multimedia handling. This article consolidates all the key concepts, common pitfalls, and worked examples you need to know.

在计算机科学中,数据通过二进制数字(比特)以及更高级的编码来表示,从而使文字、图像、声音和数字能够被数字系统存储和处理。掌握数据表示是IB和AQA计算机科学考试的核心,因为它为从内存寻址到多媒体处理等一切内容奠定了基础。本文汇总了你需要了解的所有关键概念、常见易错点和解题范例。


1. Number Systems: Binary, Denary, Hexadecimal | 数制:二进制、十进制、十六进制

Computers operate on binary (base‑2) because digital circuits can reliably distinguish two voltage levels. Denary (base‑10) is the human‐friendly system, and hexadecimal (base‑16) provides a compact way to write large binary values. In hexadecimal, digits 10–15 are represented by letters A–F. Each hex digit corresponds to a nibble (4 bits), making conversions straightforward.

计算机使用二进制(基数为2)工作,因为数字电路能够可靠地区分两种电压状态。十进制(基数为10)是人类常用的系统,而十六进制(基数为16)提供了一种书写大型二进制值的简洁方式。在十六进制中,数字10到15用字母A到F表示。每个十六进制数字对应一个半字节(4个比特),使得转换非常直接。

  • Binary: digits 0, 1; place values … 2³ 2² 2¹ 2⁰
  • Denary: digits 0–9; place values … 10³ 10² 10¹ 10⁰
  • Hexadecimal: digits 0–9, A–F; place values … 16³ 16² 16¹ 16⁰
  • 二进制:数字0、1;位值 …… 2³ 2² 2¹ 2⁰
  • 十进制:数字0–9;位值 …… 10³ 10² 10¹ 10⁰
  • 十六进制:数字0–9、A–F;位值 …… 16³ 16² 16¹ 16⁰

Example: the binary 1101 1010₂ = DA₁₆ = 218₁₀.

示例:二进制 1101 1010₂ = DA₁₆ = 218₁₀。


2. Conversions Between Bases | 进制转换

Converting between denary, binary, and hexadecimal is a fundamental skill. To convert denary to binary, repeatedly divide by 2 and read the remainders backwards. For denary to hexadecimal, divide by 16. Binary to hexadecimal: group bits into nibbles from the right, then convert each group. Hexadecimal to binary: expand each hex digit to a 4‑bit nibble.

在十进制、二进制和十六进制之间进行转换是一项基本技能。十进制转二进制:反复除以2并反向读取余数。十进制转十六进制:除以16。二进制转十六进制:从右侧起将比特分成半字节,然后转换每个组。十六进制转二进制:将每个十六进制数字展开为4比特的半字节。

Worked example: Convert 200₁₀ to binary and hex.

解题示例:将 200₁₀ 转换为二进制和十六进制。

  • 200 ÷ 2 = 100 rem 0 → 100 ÷ 2 = 50 rem 0 → 50 ÷ 2 = 25 rem 0 → 25 ÷ 2 = 12 rem 1 → 12 ÷ 2 = 6 rem 0 → 6 ÷ 2 = 3 rem 0 → 3 ÷ 2 = 1 rem 1 → 1 ÷ 2 = 0 rem 1. Read remainders backwards: 1100 1000₂.
  • 200 ÷ 16 = 12 rem 8 → 12 = C, remainder 8 → C8₁₆.
  • 200 ÷ 2 = 100 余 0 → 100 ÷ 2 = 50 余 0 → 50 ÷ 2 = 25 余 0 → 25 ÷ 2 = 12 余 1 → 12 ÷ 2 = 6 余 0 → 6 ÷ 2 = 3 余 0 → 3 ÷ 2 = 1 余 1 → 1 ÷ 2 = 0 余 1。反向读取余数:1100 1000₂。
  • 200 ÷ 16 = 12 余 8 → 12 = C,余数8 → C8₁₆。

3. Binary Arithmetic: Addition and Overflow | 二进制算术:加法与溢出

Binary addition follows the same column‑based rules as denary, with carry‑over when the sum of two bits equals 2 (10₂) or 3 (11₂). A fixed number of bits can lead to an overflow error when the result is too large to be represented. In an 8‑bit register, adding two positive numbers that exceed 127₁₀ can cause an overflow, flipping the sign bit incorrectly in two’s complement representation.

二进制加法遵循与十进制相同的按列运算规则,当两个比特之和等于2(10₂)或3(11₂)时会产生进位。在固定比特数下,当结果超出可表示范围时会产生溢出错误。在8位寄存器中,如果两个正数相加超过127₁₀,可能会发生溢出,导致在补码表示中错误地翻转符号位。

Example: 0110 1101₂ + 0001 0110₂ = 1000 0011₂ (if interpreted as unsigned, 131; as two’s complement, overflow detected).

示例: 0110 1101₂ + 0001 0110₂ = 1000 0011₂(若视为无符号数则为131;若为补码则检测到溢出)。

Exam boards often ask students to identify overflow by comparing carry‑in and carry‑out of the most significant bit; if they differ, overflow has occurred.

考试局常要求学生通过比较最高位的进位输入和输出来识别溢出;若两者不同,则发生溢出。


4. Negative Numbers: Sign‑Magnitude and Two’s Complement | 负数表示:原码与补码

Several methods represent negative integers. Sign‑magnitude uses the most significant bit as a sign bit (0 for positive, 1 for negative) and the remaining bits for magnitude. This creates two zeros (+0 and –0) and complicates arithmetic. Two’s complement is the standard because it eliminates the double zero and simplifies hardware for addition and subtraction. To negate a number in two’s complement, invert all bits and add 1. The range for an n‑bit two’s complement integer is –2ⁿ⁻¹ to 2ⁿ⁻¹ –1.

表示负整数有多种方法。原码使用最高位作为符号位(0为正,1为负),其余位表示数值。这会产生两个零(+0和–0),并使算术运算复杂化。补码(二补数)是标准方法,因为它消除了双零问题,并简化了加法和减法硬件。在补码中求负数:将所有位取反后加1。n位补码整数的范围是 –2ⁿ⁻¹ 到 2ⁿ⁻¹ –1。

8‑bit Two’s Complement: 0111 1111₂ = +127; invert → 1000 0000, add 1 → 1000 0001₂ = –127. The most negative is 1000 0000₂ = –128.

8位补码:0111 1111₂ = +127;取反 → 1000 0000,加1 → 1000 0001₂ = –127。最小的负数是 1000 0000₂ = –128。


5. Floating Point Representation | 浮点表示

Floating point stores real numbers in the form ±mantissa × baseexponent. In binary, the base is 2. A typical format allocates a sign bit, a fixed number of bits for the mantissa (fractional part), and the remaining bits for the exponent (stored in two’s complement or biased). Increasing mantissa bits improves precision, while more exponent bits extend the range. The binary point is placed immediately after the sign bit before normalisation, but for normalised floating point, the mantissa must start with 10₂ or 01₂ to maximise storage of significant digits.

浮点表示将实数存储为 ±尾数 × 基数指数 的形式。二进制中基数为2。典型格式分配一个符号位、固定数量的尾数位(小数部分)和剩余的指数位(采用补码或移码存储)。增加尾数位可提高精度,而增加指数位则扩大表示范围。二进制小数点位于符号位之后归一化前,但在规格化浮点数中,尾数必须以 10₂ 或 01₂ 开头,以最大化有效数字的存储。

Example: Represent –3.5 in 16‑bit floating point with 10‑bit mantissa and 6‑bit exponent. –3.5 = –11.1₂ = –0.111 × 2². Normalise to –0.111000000 × 2². Mantissa: 1 111000000 (sign‑magnitude or two’s complement? Exam guidance varies; often two’s complement is used for both parts). Exponent: 2 = 000010₂. Full word: 1111000000 000010.

示例:用16位浮点数(10位尾数、6位指数)表示 –3.5。–3.5 = –11.1₂ = –0.111 × 2²。规格化得到 –0.111000000 × 2²。尾数:1 111000000(采用原码还是补码?不同考试指南略有差异;常对两部分均使用补码)。指数:2 = 000010₂。完整字:1111000000 000010。


6. Character Encoding: ASCII and Unicode | 字符编码:ASCII与Unicode

Text is stored as numeric codes. ASCII originally used 7 bits, encoding 128 characters including control codes, digits, uppercase and lowercase letters, and punctuation. Extended ASCII used 8 bits (256 characters) to include symbols and accented letters. Unicode was developed to cover virtually all writing systems, using encodings such as UTF‑8, UTF‑16, and UTF‑32. UTF‑8 is backward compatible with ASCII for codes 0–127, making it the dominant encoding for the web.

文本以数字代码形式存储。ASCII最初使用7位,编码128个字符,包括控制码、数字、大小写字母和标点。扩展ASCII使用8位(256个字符)以包含符号和带重音的字母。Unicode是为涵盖几乎所有书写系统而开发的,使用诸如UTF‑8、UTF‑16和UTF‑32等编码。UTF‑8在0–127代码范围内与ASCII向后兼容,这使其成为网络的主导编码。

Key comparison: ASCII is simple but limited to English scripts. Unicode supports multilingual text but requires more bytes per character in some encodings (UTF‑16 uses 2 or 4 bytes; UTF‑8 uses 1–4 bytes).

关键对比:ASCII简单但仅限于英文书写体系。Unicode支持多语言文本,但在某些编码中每个字符需要更多字节(UTF‑16使用2或4字节;UTF‑8使用1至4字节)。


7. Representing Images: Pixels, Resolution and Colour Depth | 图像表示:像素、分辨率与颜色深度

Bitmap images are stored as a grid of pixels. Each pixel’s colour is defined by a binary value. The number of bits per pixel (colour depth) determines the number of available colours: n bits gives 2ⁿ colours. For example, 1 bit per pixel supports black and white; 8 bits per pixel supports 256 colours; 24 bits (3 bytes, Truecolour) supports over 16 million colours by combining red, green, and blue components. Resolution is the total number of pixels (width × height), affecting detail and image file size.

位图图像以像素网格形式存储。每个像素的颜色由一个二进制值定义。每像素的比特数(颜色深度)决定了可用颜色的数量:n位可得到 2ⁿ 种颜色。例如,每像素1位支持黑白两色;每像素8位支持256种颜色;24位(3字节,真彩色)通过组合红、绿、蓝分量支持超过1600万种颜色。分辨率是像素总数(宽 × 高),影响细节和图像文件大小。

File size (bits) = width × height × colour depth

文件大小(比特)= 宽度 × 高度 × 颜色深度

Metadata such as width, height, and colour table are also stored in image files, adding overhead.

图像文件中还存储宽度、高度和颜色表等元数据,会带来额外开销。


8. Representing Sound: Sampling and Bit Depth | 声音表示:采样与位深度

Sound is analogue by nature, so to store it digitally it must be sampled at discrete intervals. The sampling rate (in Hz) is the number of samples taken per second. The bit depth (sample resolution) is the number of bits used to store each sample. Higher sampling rates and bit depths give better fidelity but increase file size. The Nyquist theorem states that the sampling rate must be at least twice the highest frequency in the signal to avoid aliasing.

声音本质上是模拟的,因此必须以离散间隔进行采样才能数字化存储。采样率(单位Hz)是每秒采集的样本数。位深度(采样分辨率)是每个样本存储所用的比特数。提高采样率和位深度可获得更好的保真度,但会增加文件大小。奈奎斯特定理指出,为避免混叠,采样率必须至少是信号中最高频率的两倍。

Sound file size (bits) = sampling rate × bit depth × duration (seconds) × number of channels

声音文件大小(比特)= 采样率 × 位深度 × 时长(秒)× 声道数

For CD quality, the sampling rate is 44.1 kHz, bit depth 16 bits, with two channels (stereo). That gives a bit rate of 44 100 × 16 × 2 ≈ 1.41 Mbps.

CD音质的采样率为44.1 kHz,位深度为16位,双声道(立体声)。这产生的比特率为 44 100 × 16 × 2 ≈ 1.41 Mbps。


9. Data Compression: Lossy vs Lossless | 数据压缩:有损与无损

Compression reduces the number of bits needed to represent data, saving storage space and transmission time. Lossless compression preserves every bit of the original data; typical algorithms include run‑length encoding (RLE) and dictionary‑based methods (LZW, used in ZIP). Lossy compression permanently discards some information that is less perceptible to humans, achieving much higher compression ratios, and is used for JPEG (images), MP3 (audio), and MPEG (video).

压缩可减少表示数据所需的比特数,从而节省存储空间和传输时间。无损压缩保留原始数据的每一个比特;典型算法包括游程编码(RLE)和基于字典的方法(LZW,用于ZIP)。有损压缩会永久丢弃一些人类不易察觉的信息,从而获得更高的压缩比,常用于JPEG(图像)、MP3(音频)和MPEG(视频)。

Example of RLE: Original: AAAAAABBBBBCCCDD → Compressed: 6A5B3C2D. For images with repeating colours, RLE can be very effective.

RLE示例:原始数据:AAAAAABBBBBCCCDD → 压缩后:6A5B3C2D。对于颜色重复的图像,RLE非常有效。

Feature Lossless Lossy
Data recovery Exact original restored Some data permanently lost
Compression ratio Typically 2:1 to 3:1 10:1 or higher
Typical use Text, source code, PNG images Photographs, music, video
特性 无损压缩 有损压缩
数据恢复 精确还原原始数据 部分数据永久丢失
压缩比 通常 2:1 至 3:1 10:1 或更高
典型应用 文本、源代码、PNG图像 照片、音乐、视频

10. Error Detection: Parity, Checksums, CRCs | 错误检测:奇偶校验、校验和、循环冗余校验

When data is transmitted or stored, errors may occur. Parity bits add a single bit to make the number of 1s either even (even parity) or odd (odd parity). If a single bit flips, the parity check fails, but it cannot detect an even number of bit flips and cannot correct errors. Checksums involve summing data bytes and appending the sum; the receiver recomputes and compares. More robust methods like Cyclic Redundancy Check (CRC) use polynomial division to detect burst errors, commonly used in networks and storage.

数据在传输或存储时可能发生错误。奇偶校验位添加一个比特,使1的个数为偶数(偶校验)或奇数(奇校验)。如果单个比特翻转,校验会失败,但无法检测偶数个比特的翻转,也不能纠错。校验和通过将数据字节求和并附加和值;接收方重新计算并比较。循环冗余校验(CRC)等更可靠的方法使用多项式除法检测突发错误,广泛用于网络和存储设备。

Example: 7‑bit ASCII ‘A’ = 100 0001. Using even parity, the parity bit is 0 because there are two 1s already. Transmitted byte: 0100 0001. If received as 0100 0011 (two bit flips), parity check passes mistakenly.

示例:7位ASCII字符 ‘A’ = 100 0001。采用偶校验时,由于已有两个1,校验位为0。传输字节:0100 0001。若接收到的为0100 0011(两个位翻转),奇偶校验会错误地通过。

CRCs can detect many common errors and are specified by a generator polynomial; AQA often references the CRC‑16‑CCITT standard.

CRC可以检测许多常见错误,并由生成多项式规定;AQA常参考CRC‑16‑CCITT标准。


Published by TutorHao | Computer Science Revision Series | aleveler.com

更多咨询请联系16621398022(同微信)

Comments

屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from aleveler.com

Subscribe now to keep reading and get access to the full archive.

Continue reading