📚 IB & CCEA Computer Science: Calculation Practice | IB与CCEA计算机:计算题专项训练
Calculation questions form the backbone of any computer science exam, whether you are sitting an IB Paper 1 or a CCEA AS/A2 unit. They test your fluency in number systems, logic, data representation, and network performance. In this revision guide we walk through the most common calculation types found across both syllabi, with worked examples and dual-language explanations to strengthen your exam technique.
计算题是任何计算机科学考试的核心,不论你参加的是IB试卷一还是CCEA AS/A2单元。这些题目考查你对数制、逻辑、数据表示和网络性能的掌握程度。在本复习指南中,我们将梳理两大课程体系中最常见的计算题型,配合完整的例题和中英双语讲解,帮助你提升应试技巧。
1. Binary and Decimal Conversions | 二进制与十进制转换
In both IB and CCEA, the ability to convert between binary and decimal is assumed knowledge. For a binary number such as 10110₂, each bit corresponds to a power of 2. Starting from the rightmost bit at position 0, the value is 0×2⁰ + 1×2¹ + 1×2² + 0×2³ + 1×2⁴ = 0 + 2 + 4 + 0 + 16 = 22 in decimal.
在IB和CCEA考试中,二进制与十进制的转换是必备技能。以二进制数 10110₂ 为例,每一位对应一个2的幂次。从右端第0位开始,其值为 0×2⁰ + 1×2¹ + 1×2² + 0×2³ + 1×2⁴ = 0 + 2 + 4 + 0 + 16 = 22(十进制)。
| Power of 2 | 2⁴ | 2³ | 2² | 2¹ | 2⁰ |
|---|---|---|---|---|---|
| Bit | 1 | 0 | 1 | 1 | 0 |
For decimal to binary, repeatedly divide the number by 2 and record the remainders. Example: convert 53 to binary. 53 ÷ 2 = 26 R1; 26 ÷ 2 = 13 R0; 13 ÷ 2 = 6 R1; 6 ÷ 2 = 3 R0; 3 ÷ 2 = 1 R1; 1 ÷ 2 = 0 R1. Reading remainders bottom‑up gives 110101₂.
十进制转二进制时,反复除以2并记录余数。示例:将53转换为二进制。53÷2=26余1;26÷2=13余0;13÷2=6余1;6÷2=3余0;3÷2=1余1;1÷2=0余1。由下往上读取余数得到110101₂。
2. Hexadecimal Conversions | 十六进制转换
Hexadecimal is a compact way to express binary values. Each hex digit represents 4 bits (a nibble). To convert binary 11010110₂ to hex, split into nibbles: 1101 (D) and 0110 (6), giving D6₁₆. Decimal to hex: 214 ÷ 16 = 13 R6, where 13 is D, yielding D6₁₆.
十六进制是表示二进制值的紧凑方式。每个十六进制位代表4个二进制位(一个半字节)。将二进制11010110₂转换为十六进制,拆分为半字节:1101(D)和0110(6),得到D6₁₆。十进制转十六进制:214÷16=13余6,13即D,结果为D6₁₆。
Binary 1101 0110 → Hex D6₁₆
3. Binary Arithmetic: Addition and Multiplication | 二进制算术:加法与乘法
Binary addition follows simple rules: 0+0=0, 0+1=1, 1+0=1, 1+1=0 (carry 1). Add 1011₂ (11) and 0110₂ (6). Rightmost: 1+0=1; next: 1+1=0 carry 1; then: 1+1+0 carry = 0 carry 1; leftmost: 1+1+0 carry = 0 carry 1, result 10001₂ (17).
二进制加法遵循简单规则:0+0=0,0+1=1,1+0=1,1+1=0(进1)。将1011₂(11)与0110₂(6)相加。最右:1+0=1;次位:1+1=0进1;再次:1+1+0进位=0进1;最左:1+1+0进位=0进1,结果为10001₂(17)。
Binary multiplication is similar to long multiplication but easier because you multiply only by 0 or 1. 101₂ (5) × 11₂ (3): 101 × 1 = 101; 101 × 1 (shifted) = 1010; sum = 1111₂ (15).
二进制乘法类似于长乘法但更简单,因为乘数只是0或1。101₂(5)×11₂(3):101×1=101;101×1(移位)=1010;求和为1111₂(15)。
4. Negative Numbers: Two’s Complement | 负数表示:二进制补码
IB and CCEA both cover two’s complement for signed integers. To represent –6 in an 8‑bit system, start with +6 (00000110₂), invert all bits → 11111001, then add 1 → 11111010₂. The most significant bit (MSB) is 1, confirming a negative number. Range for 8 bits: –128 to +127.
IB和CCEA均涵盖带符号整数的补码表示。在8位系统中表示–6,从+6(00000110₂)开始,所有位取反→11111001,再加1→11111010₂。最高有效位(MSB)为1,表明负数。8位表示的范围:–128到+127。
–6 in two’s complement (8-bit): 11111010₂
5. Floating Point Representation | 浮点数表示
A binary floating point number consists of a mantissa and an exponent. For instance, the decimal 6.5 in IEEE‑style 8‑bit format with a 4‑bit mantissa and 4‑bit exponent: 6.5 = 110.1₂ = 0.1101 × 2³. Mantissa (0.1101) stored as 1101, exponent (3) as 0011 in excess‑7 (3+7=10 → 1010) or two’s complement depending on syllabus. IB typically uses two’s complement exponent; CCEA may use bias. Always check the specification.
二进制浮点数由尾数和阶码组成。例如,十进制6.5在4位尾数、4位阶码的IEEE风格8位格式中:6.5=110.1₂=0.1101×2³。尾数0.1101存储为1101,阶码3在移码(余7码)中为3+7=10→1010,或根据课程使用补码。IB常使用二进制补码阶码,CCEA可能使用偏移量。务必查阅对应考纲。
6.5 as floating point binary: Mantissa 1101, Exponent 1010 (excess‑7)
6. Logic Gates and Truth Tables | 逻辑门与真值表
Calculation of logic circuits often requires completing truth tables and simplifying Boolean expressions. For a circuit with inputs A, B and output Q = (A AND B) OR (NOT A), build the table: A=0,B=0→Q=(0 AND 0) OR 1 = 1; A=0,B=1→(0 AND 1) OR 1 = 1; A=1,B=0→(0) OR 0 = 0; A=1,B=1→(1) OR 0 = 1. Such tables are straightforward but must be systematic.
逻辑电路的计算通常要求完成真值表并化简布尔表达式。对于输入为A、B,输出为Q = (A AND B) OR (NOT A)的电路,构建真值表:A=0,B=0→Q=(0 AND 0) OR 1=1;A=0,B=1→(0 AND 1) OR 1=1;A=1,B=0→(0) OR 0=0;A=1,B=1→(1) OR 0=1。这类表格虽简单,但需按部就班完成。
| A | B | A AND B | NOT A | Q |
|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 0 | 1 |
7. Boolean Algebra Simplification | 布尔代数化简
IB Paper 1 and CCEA A2 require simplification using Boolean laws. For example, simplify F = A • B • C + A • B • C’ + A • B’. Factorising: A • B • (C + C’) + A • B’ = A • B • 1 + A • B’ = A • B + A • B’ = A • (B + B’) = A • 1 = A. Thus the circuit reduces to a single wire A.
IB试卷一与CCEA A2均要求利用布尔定律进行化简。例如,化简F = A·B·C + A·B·C’ + A·B’。提取公因式:A·B·(C + C’) + A·B’ = A·B·1 + A·B’ = A·B + A·B’ = A·(B + B’) = A·1 = A。因此电路简化为单一输入A。
F = A · B · C + A · B · C’ + A · B’ = A
8. Data Storage Capacity | 数据存储容量计算
Exam questions often ask for the number of addressable locations or the capacity of a memory chip. If a RAM chip has 12 address lines, it can address 2¹² = 4096 locations. If each location stores 8 bits (1 byte), the capacity is 4096 bytes, or 4 KB. For CCEA, you may also calculate the number of bits needed to address a given memory size: to address 512 KB, you need log₂(512 × 1024) = log₂(524288) ≈ 19 address lines.
考试题经常询问可寻址位置数或存储芯片的容量。若RAM芯片有12根地址线,可寻址2¹²=4096个位置。若每个位置存储8位(1字节),则容量为4096字节,即4 KB。对CCEA而言,还可能要求计算寻址给定存储容量所需的位数:要寻址512 KB,需要log₂(512×1024)=log₂(524288)≈19根地址线。
Number of addresses = 2n, where n = number of address lines
9. Image and Sound File Size | 图像与声音文件大小
Image file size = resolution width × height × colour depth (bits). For a 1024 × 768 bitmap with 24‑bit colour, uncompressed size = 1024 × 768 × 24 = 18,874,368 bits = 2,359,296 bytes ≈ 2.25 MiB. Sound file size = sample rate (Hz) × sample depth (bits) × duration (s) × number of channels. For 60 seconds of stereo audio at 44.1 kHz, 16‑bit: 44100 × 16 × 60 × 2 = 84,672,000 bits ≈ 10.09 MB.
图像文件大小 = 分辨率宽×高×色深(位)。一幅1024×768的24位真彩色位图,未压缩大小为1024×768×24 = 18,874,368位 ≈ 2.25 MiB。声音文件大小 = 采样率(Hz)×采样深度(位)×时长(秒)×声道数。60秒立体声音频,44.1 kHz,16位:44100×16×60×2 = 84,672,000位 ≈ 10.09 MB。
Sound filesize = Sample Rate × Bit Depth × Duration × Channels
10. Network Transmission Time | 网络传输时间
Transmission time = file size / bit rate. Be careful to match units. If a 5 MB file is transmitted over a 100 Mbps link, convert file size to bits: 5 MB = 5 × 1024 × 1024 × 8 = 41,943,040 bits. Bit rate = 100 × 10⁶ bps. Time = 41,943,040 / 100,000,000 = 0.419 s. Remember that CCEA may define 1 MB = 1000 × 1000 bytes in some contexts—always check the paper’s convention.
传输时间 = 文件大小 / 比特率。注意单位匹配。若通过100 Mbps链路传输5 MB文件,将文件大小转换为位:5 MB = 5×1024×1024×8 = 41,943,040 位。比特率 = 100×10⁶ bps。时间 = 41,943,040 / 100,000,000 = 0.419秒。记住CCEA在某些上下文中可能定义1 MB = 1000×1000字节,务必查看试题约定。
Transmission Time = (File Size in bits) / (Transmission Rate in bps)
11. Compression Ratios | 压缩比计算
Both IB and CCEA expect you to calculate compression ratios. Suppose an original file is 2 MB and the compressed version is 512 KB. First convert to the same unit: 2 MB = 2048 KB. Compression ratio = original size / compressed size = 2048 / 512 = 4:1. You might also be asked for the percentage reduction: (2048 − 512) / 2048 × 100 = 75%.
IB和CCEA都要求计算压缩比。假设原始文件2 MB,压缩版本512 KB。先统一单位:2 MB = 2048 KB。压缩比 = 原始大小 / 压缩后大小 = 2048 / 512 = 4:1。还可能要求计算缩减百分比:(2048−512)/2048×100 = 75%。
Compression Ratio = Original Size : Compressed Size
12. Bitwise Operations and Masks | 按位运算与掩码
IB students may encounter bitwise AND, OR, XOR and shifts. To extract the lower 4 bits of a byte, use a mask: 10101101₂ AND 00001111₂ = 00001101₂. Shifts can be used for fast multiplication or division by powers of 2. For example, shifting 0001011₂ (11) left by 2 positions gives 0101100₂ (44), which is 11 × 4.
IB学生可能会遇到按位与、或、异或和移位运算。要提取一个字节的低4位,使用掩码:10101101₂ AND 00001111₂ = 00001101₂。移位可用于快速进行2的幂次乘法或除法。例如,将0001011₂(11)左移2位得到0101100₂(44),即11×4。
Left shift by n: value × 2n; Right shift: value ÷ 2n (integer division)
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课程辅导,国外大学本科硕士研究生博士课程论文辅导