📚 Data Representation Exam Essentials for IB & Edexcel | IB Edexcel 计算机 数据表示 考点精讲
Data representation forms the bedrock of all computer science. From integers to multimedia, every piece of information is ultimately stored as binary digits. A solid grasp of number systems, negative integers, floating-point, character encoding, and media storage is essential for top marks in the IB Computer Science and Edexcel International A Level exams.
数据表示是所有计算机科学的基石。从整数到多媒体,每一条信息最终都以二进制位的形式存储。扎实掌握数制系统、负整数、浮点数、字符编码以及媒体存储,是 IB 计算机科学和 Edexcel 国际 A Level 考试取得高分的关键。
1. Number Systems & Conversions | 数制系统与转换
Digital systems use binary (base 2) because they only recognise two states: off (0) and on (1). To make long binary strings more readable we use hexadecimal (base 16), which groups four bits into one hex digit. The digits 0–9 represent values zero to nine, while A, B, C, D, E, F represent 10 to 15.
数字系统使用二进制(基数为 2),因为它只识别两种状态:关(0)和开(1)。为了让长二进制串更易读,我们使用十六进制(基数为 16),将四个位组合成一个十六进制数字。数字 0–9 代表零到九,而 A、B、C、D、E、F 代表 10 到 15。
Converting from binary to decimal involves writing the binary number as a sum of powers of two. For example, 1101₂ means 1×2³ + 1×2² + 0×2¹ + 1×2⁰ = 8 + 4 + 0 + 1 = 13₁₀.
从二进制转换到十进制就是将二进制写成 2 的幂次之和。例如 1101₂ 表示 1×2³ + 1×2² + 0×2¹ + 1×2⁰ = 8 + 4 + 0 + 1 = 13₁₀。
To convert binary to hex, split the bits into groups of four starting from the right. Thus 11100110₂ becomes 1110 0110, which is E6₁₆. Going the other way, each hex digit expands to four bits: 2F₁₆ = 0010 1111₂.
将二进制转换为十六进制,从右边开始每四位一组进行拆分。因此 11100110₂ 变为 1110 0110,即 E6₁₆。反过来,每个十六进制数字扩展为四位:2F₁₆ = 0010 1111₂。
| Decimal | Binary | Hex |
|---|---|---|
| 0 | 0000 | 0 |
| 1 | 0001 | 1 |
| 8 | 1000 | 8 |
| 15 | 1111 | F |
2. Binary Arithmetic | 二进制算术
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. Subtraction can be performed directly by borrowing, but in most digital systems it is done by adding the two’s complement of the subtrahend.
二进制加法遵循简单的规则:0+0=0,0+1=1,1+0=1,1+1=0 并且向下一列进位 1。减法可以直接通过借位来执行,但在大多数数字系统中,减法是通过加上减数的补码来实现的。
Example: 0110₂ (6) + 0101₂ (5) = 1011₂ (11)
示例:0110₂ (6) + 0101₂ (5) = 1011₂ (11)。
When adding two n-bit numbers produces a result that requires n+1 bits, an overflow error occurs. For instance, adding 1000₂ and 1001₂ in a 4‑bit two’s‑complement system gives 10001₂, but the leftmost carry is lost, producing 0001₂ – a wrong result.
当两个 n 位数相加产生需要 n+1 位的结果时,就会发生溢出错误。例如,在 4 位补码系统中将 1000₂ 和 1001₂ 相加得到 10001₂,但最左侧的进位会丢失,产生 0001₂ —— 一个错误的结果。
3. Two’s Complement Representation | 补码表示
To represent both positive and negative integers, modern computers use two’s complement. In an n‑bit pattern, the most significant bit (MSB) is the sign bit: 0 for positive, 1 for negative. The remaining n−1 bits give the magnitude for positive numbers and the inverted+1 magnitude for negative numbers.
为了表示正负整数,现代计算机使用补码。在一个 n 位模式中,最高有效位(MSB)是符号位:0 表示正数,1 表示负数。剩下的 n−1 位为正数提供数值大小,为负数提供取反加一后的大小。
The range of two’s complement numbers is from −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1. For an 8‑bit representation, that is −128 to 127.
补码数的范围是从 −2ⁿ⁻¹ 到 2ⁿ⁻¹ − 1。对于 8 位表示,即 −128 到 127。
To find the negative of a number: invert all bits (one’s complement) and then add 1. For +6 (00000110), invert to 11111001, add 1 → 11111010, which represents −6.
求一个数的负数:将所有位取反(反码)然后加 1。对于 +6(00000110),取反得 11111001,加 1 → 11111010,表示 −6。
Two’s complement subtraction is performed by adding the two’s complement of the subtrahend. For instance, 5 − 3 = 0101₂ + (two’s complement of 0011₂ = 1101₂) = 10010₂; the carry out of the 4‑bit limit is ignored, leaving 0010₂ = 2, which is correct.
补码减法是通过加上减数的补码来实现的。例如,5 − 3 = 0101₂ + (0011₂ 的补码 = 1101₂)= 10010₂;溢出 4 位边界的进位被忽略,留下 0010₂ = 2,结果正确。
4. Floating Point Representation | 浮点数表示
Real numbers are stored in floating‑point format, typically following the IEEE 754 standard. A single‑precision (32‑bit) number has 1 bit for the sign (S), 8 bits for the exponent (E) biased by 127, and 23 bits for the mantissa (M). The value is:
实数以浮点格式存储,通常遵循 IEEE 754 标准。单精度(32 位)数有 1 位符号(S),8 位指数(E)偏移 127,以及 23 位尾数(M)。其值为:
Value = (−1)^S × 1.M × 2^(E − 127)
值 = (−1)^S × 1.M × 2^(E − 127)
Before storage, the binary number is normalised so that there is a single ‘1’ before the binary point; this hidden bit is not stored, yielding an extra bit of precision. The exponent is stored as biased exponent = true exponent + 127.
存储前,二进制数会被规格化,使得小数点前有一个 ‘1’;这个隐藏位不存储,从而额外增加了一位精度。指数以偏移指数 = 真实指数 + 127 的形式存储。
Example: convert 10.25 (1010.01₂) to IEEE 754. Normalise to 1.01001 × 2³. S = 0, true exponent = 3, biased exponent = 130 (10000010₂), mantissa = 01001 followed by 18 zeros. The 32‑bit pattern is 0 10000010 01001000000000000000000.
示例:将 10.25(1010.01₂)转换为 IEEE 754。规格化为 1.01001 × 2³。S = 0,真实指数 = 3,偏移指数 = 130(10000010₂),尾数 = 01001 后跟 18 个 0。32 位模式为 0 10000010 01001000000000000000000。
Special values such as NaN and infinity are represented by reserved exponent values. Edexcel and IB candidates should be able to convert a floating‑point binary back to decimal and explain the trade‑off between range and precision.
特殊值如 NaN 和无穷大由保留的指数值表示。Edexcel 和 IB 考生应能够将浮点二进制转换回十进制,并解释范围与精度之间的权衡。
5. Character Encoding | 字符编码
Characters are represented by assigning numeric codes. ASCII uses 7 bits (0–127) to encode English letters, digits, punctuation and control characters. Extended ASCII adds an 8th bit to cover another 128 symbols, such as accented characters, but still cannot cover all world scripts.
字符通过分配数字代码来表示。ASCII 使用 7 位(0–127)来编码英文字母、数字、标点和控制字符。扩展 ASCII 增加了第 8 位以涵盖另外 128 个符号,如重音字符,但仍无法覆盖世界所有文字系统。
Unicode was developed to support every writing system. It uses code points that can be encoded with variable‑length schemes: UTF‑8 uses 1‑4 bytes, UTF‑16 uses 2 or 4 bytes, and UTF‑32 always uses 4 bytes. The first 128 Unicode code points match ASCII, ensuring backward compatibility.
Unicode 的开发旨在支持所有书写系统。它使用码点,可通过变长方案编码:UTF‑8 使用 1 至 4 字节,UTF‑16 使用 2 或 4 字节,UTF‑32 始终使用 4 字节。前 128 个 Unicode 码点与 ASCII 匹配,确保了向后兼容。
When calculating storage, remember that plain ASCII text requires 1 byte per character. If a question specifies UTF‑16, each character may take 2 or 4 bytes. Knowing the hex value of common characters (e.g., ‘A’ = 65₁₀ = 41₁₆) is useful for paper analysis.
在计算存储时,记住纯 ASCII 文本每个字符需要 1 字节。如果题目指定 UTF‑16,每个字符可能占用 2 或 4 字节。知道常见字符的十六进制值(例如 ‘A’ = 65₁₀ = 41₁₆)对试卷分析很有用。
6. Representing Images | 图像表示
Bitmap (raster) images are built from a grid of picture elements called pixels. Each pixel is assigned a colour that is stored as a binary number. The colour depth specifies how many bits are used per pixel: 1‑bit gives 2 colours, 8‑bit gives 256 colours, and 24‑bit true colour provides about 16.7 million colours.
位图(光栅)图像由称为像素的图片元素网格构建。每个像素被分配一种颜色,以二进制数字存储。颜色深度指定每个像素使用的位数:1 位给出 2 种颜色,8 位给出 256 种颜色,24 位真彩色提供约 1670 万种颜色。
Image metadata includes the width, height and colour depth, allowing the file size to be calculated:
图像元数据包括宽度、高度和颜色深度,从而可以计算文件大小:
Uncompressed image size (bits) = width × height × colour depth
未压缩图像大小(位)= 宽度 × 高度 × 颜色深度
So an 800 × 600 image at 24‑bit colour requires 800×600×24 = 11,520,000 bits, which is 1,440,000 bytes or about 1.37 MiB. Vector graphics, on the other hand, store mathematical descriptions of shapes and scale without loss of quality.
因此,一幅 800 × 600、24 位颜色的图像需要 800×600×24 = 11,520,000 位,即 1,440,000 字节或约 1.37 MiB。另一方面,矢量图形存储形状的数学描述,并且缩放时不损失质量。
7. Representing Sound | 声音表示
Sound is an analogue wave. To digitise it, the amplitude is measured at regular intervals – the sampling rate, measured in hertz (Hz). Each sample is quantised to a certain bit depth, determining the dynamic range (e.g., 16‑bit gives 65,536 levels). More samples per second and higher bit depth improve quality but increase file size.
Published by TutorHao | IB 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