A Adam Learning
Back to notes
9618-AS-01-01Chapter 1Section 1.1comprehensive

1.1 Data Representation 数据表示

Review the exact wording students need for this knowledge point, then open a filtered question list when ready to practise.

Find questions for 9618-AS-01-01

Syllabus learning goals 考纲学习目标

第一次学习本章? 先阅读完整的 Chapter 1.1 Data Representation 课本教材。教材从 bit 和位权开始,并在每个阶段安排练习与 Past Paper 原题;本页继续作为考前复习与 Mark Scheme wording 总结。

完成本节后,学生需要能够:

  • 理解 binary magnitudes,并区分 binary prefixesdecimal prefixes:kibi/kilo、mebi/mega、gibi/giga、tebi/tera。
  • 使用 binary、denary、hexadecimal、BCD、one's complement 和 two's complement。
  • 把整数从一种 number base 或 representation 转换为另一种。
  • 使用正数和负数进行 binary addition 与 subtraction。
  • 解释 overflow 如何产生。
  • 描述 BCD 和 hexadecimal 的实际应用。
  • 根据 character set,把字符数据表示成内部二进制形式;需要熟悉 ASCII、extended ASCII 和 Unicode,但不要求背诵具体字符编码。
复习原则:计算题必须写 working;简答题按分值写独立 bullet points,并尽量使用本页加粗的 mark-scheme wording。

1 Binary and decimal prefixes 二进制与十进制前缀

计算机存储容量中会同时出现两套数量级。二进制前缀以 1024,也就是 2^10 为相邻单位的倍率;十进制前缀以 1000,也就是 10^3 为倍率。

Binary prefixValueDecimal prefixValue
kibibyte (KiB)2^10 = 1024 byteskilobyte (kB)10^3 = 1000 bytes
mebibyte (MiB)2^20 bytesmegabyte (MB)10^6 bytes
gibibyte (GiB)2^30 bytesgigabyte (GB)10^9 bytes
tebibyte (TiB)2^40 bytesterabyte (TB)10^12 bytes

Mark-scheme answer pattern

题目要求 state one difference 时,只写一个精确对比即可:

  • Kibi is a binary prefix, whereas kilo is a denary/decimal prefix.
  • A kibibyte is 1024 bytes, whereas a kilobyte is 1000 bytes.

不要只写 “KiB is larger”。这虽然可能符合事实,但没有准确说明 binary 与 decimal 的区别。

2 Number systems 数制

Binary, denary and hexadecimal

SystemBaseDigits usedPlace values
Binary20, 1..., 8, 4, 2, 1
Denary100 to 9..., 1000, 100, 10, 1
Hexadecimal160 to 9, A to F..., 4096, 256, 16, 1

一个 hexadecimal digit 正好表示 four binary bits。因此转换 binary 与 hexadecimal 时,可以从右向左每四位分组。

例:把 1101 0110 转换为 hexadecimal:

1101 = D
0110 = 6
Answer = D6

例:把 A04 转换为 denary:

A04 = (10 x 16^2) + (0 x 16^1) + (4 x 16^0)
    = 2560 + 0 + 4
    = 2564

Minimum number of bits

n bits 可以形成 2^n 个不同组合。寻找最少位数时,选择满足 2^n >= number of possible values 的最小 n

例:256 种颜色需要 8 bits,因为 2^8 = 256。数值 256 本身则需要 9-bit unsigned binary,因为 8 bits 只能表示 0 到 255。

BCD: Binary Coded Decimal

BCD 不是把整个十进制数直接转换为 binary,而是把 each denary digit separately represented by four bits

例:把 denary 108 转换为 BCD:

1     0     8
0001  0000  1000

常见错误是把 108 整体转换成 01101100。这是 pure binary,不是 BCD。

3 Negative binary representations 负数表示

One's complement

求一个正数的 one's complement 负数表示:

  • 先写出固定 bit length 的正数。
  • Invert every bit,也就是 0 变 1,1 变 0。

例:8-bit +120 = 0111 1000,所以 one's complement -120 = 1000 0111

Two's complement

求 two's complement 负数:

  • 写出固定 bit length 的正数。
  • Invert every bit
  • Add 1

例:用 8 bits 表示 -68

+68             0100 0100
Invert bits     1011 1011
Add 1           1011 1100
Therefore -68 = 1011 1100

另一种把 two's complement 转回 denary 的方法,是把 most significant bit 当作负权值。8-bit 权值为:

-128  64  32  16  8  4  2  1

因此 1001 1111 = -128 + 16 + 8 + 4 + 2 + 1 = -97

Representable ranges

Representationn-bit range
Unsigned binary0 to 2^n - 1
Two's complement-2^(n-1) to 2^(n-1) - 1

8-bit unsigned binary 的范围是 0 到 255;8-bit two's complement 的范围是 -128 到 127。

4 Binary addition and subtraction 二进制加减

Addition rules

0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 10  (write 0, carry 1)
1 + 1 + 1 = 11  (write 1, carry 1)

考试中若题目有 method mark,需要清楚写出 carries。只写最终答案可能失去过程分。

Subtraction with two's complement

计算 A - B 可以改写为 A + (-B)

  • 把 B 写成固定长度 binary。
  • 求 B 的 two's complement,得到 -B。
  • 与 A 相加。
  • 保留题目指定的 bit length;超出最高位的 carry 通常丢弃,但必须另外判断是否 overflow。

例:8-bit 74 - 23

 74                 0100 1010
 23                 0001 0111
Invert 23           1110 1000
Add 1               1110 1001

  0100 1010
+ 1110 1001
------------
1 0011 0011

8-bit answer = 0011 0011 = 51

5 Overflow 溢出

Overflow 不是“计算器坏了”,而是正确数学结果超出了固定 bit length 能表示的范围。

Mark-scheme wording

  • The answer cannot be represented in the number of bits available.
  • The answer is larger than the maximum positive number that can be stored in the register.
  • The answer is smaller than the most negative number that can be stored in the register.

对于 8-bit two's complement,127 + 1 的数学答案是 128,但可表示上限只有 127,因此发生 overflow。

Carry 与 overflow 不是同一个概念。Carry 是最高位产生的进位;overflow 取决于题目采用的表示方法,以及结果是否超出该表示方法的范围。

One-mark answer pattern

Overflow occurs because the answer cannot be represented in the number of bits available.

若题目已给出具体 register,可以更有针对性地写 “the result is larger than the maximum positive value that can be stored in the 8-bit register”。

6 Practical applications of BCD and hexadecimal 实际应用

BCD applications

应用题通常一分给 application,一分给与该应用对应的 justification。必须把两者连起来。

ApplicationMark-secure justification
Financial or banking calculationsMonetary values can be represented exactly, avoiding accumulating/rounding errors caused by representing some decimal fractions in normal binary.
Electronic displays, such as calculators and digital clocksThe display uses individual denary digits, so conversion between denary and BCD is straightforward.
Date and time stored in a PC BIOSConversion between denary and BCD is straightforward.
Barcode systemsConversion between denary and BCD can be completed accurately and directly.

高质量两分答案:

BCD is used in financial calculations because monetary values need to be represented exactly, avoiding accumulating rounding errors.

Hexadecimal applications

  • HTML colour codes:每两位 hexadecimal 表示 red、green、blue 的强度,例如 #FC238A
  • Memory addresses and machine code:hexadecimal 比长串 binary 更短、更易读;一个 hex digit 与 four bits 直接对应,转换方便。
  • MAC addresses and IPv6 addresses:使用较少字符表示较长的 binary value,减少抄写错误。

解释“为什么使用 hexadecimal”时,写出两个相连的评分点:

  • It is shorter and easier for humans to read, remember and write than binary.
  • Each hexadecimal digit maps directly to four binary bits, so conversion is straightforward.

7 Character sets 字符集

Definition

Character set 是 all the characters/symbols that a computer can represent,并且 each character has a unique numeric/binary code

不要只写 “a list of characters”。第二个评分点通常要求说明 unique code。

How a word is stored

解释一个单词如何由 character set 表示时,可按两分写:

  • Each character has its own unique binary code.
  • The code for each character is stored in sequence/in the order in the word.

例如 Clock 不会以一个整体的“单词代码”存储;C、l、o、c、k 分别替换成各自的 code,再按原顺序存储。

ASCII, extended ASCII and Unicode

Character setTypical exam description
ASCII7 bits; 2^7 = 128 possible characters; mainly Latin letters, digits, punctuation and control characters.
Extended ASCII8 bits; 2^8 = 256 possible characters.
UnicodeUses more possible codes and can represent a wider range of characters, including characters from more languages and symbols such as emojis.

Compare answer pattern

若题目要求比较 ASCII 与 Unicode,分点作答:

  • Similarity: Both represent each character using a unique code.
  • Difference: Unicode can represent a wider range of characters.
  • Difference: Unicode can represent characters from more languages and symbols such as emojis.

不要把后两句当成完全相同的一点重复书写。若题目给 3 marks,应给出三个可独立评分的信息点。

8 Command words and answer construction 指令词与答题结构

Command wordWhat to write
State给出一个精确事实,不需要展开原因。
Identify写出符合要求的名称、数值或应用。
Describe写出对象是什么或过程怎样发生,通常一个独立事实对应一分。
Explain写出事实并说明 why/how,使用 because、therefore 或 so that 建立联系。
Show your working保留转换、权值、invert/add 1、carry 或 borrow 等中间步骤。

Two-mark short-answer method

  • 先看分值,准备两个独立 bullet points。
  • 每一点只表达一个可评分事实。
  • 使用精确名词,例如 unique binary codestored in sequencenumber of bits available
  • 不用模糊词,例如 “better”“more useful”“computer understands it”。

9 Past-paper checklist 真题检查表

做完 1.1 题目后检查:

  • 是否始终保持题目要求的 bit length?
  • BCD 是否按每个 denary digit 分成四位?
  • two's complement 是否清楚写了 invert 和 add 1?
  • binary addition 是否写出 carries?
  • hexadecimal 转换是否写出 place values 或四位分组?
  • overflow 是否明确联系到 representable range 或 number of bits available?
  • 应用题是否同时写了 application 和 matching justification?
  • character set 简答是否写到 unique code 和 stored in sequence?

本材料依据 9618 syllabus 1.1 的七项要求,并综合本页所列 2021-2025 past-paper questions 及其 mark schemes。示例数值用于教学演示;答题措辞优先保留反复出现、可独立得分的 mark-scheme language。

Practice This Knowledge Point

Open the question bank with this knowledge code already filled in. The filtered list will show matching questions for this note.

Open filtered practice
Source questions used