IB & AQA Computer Science Calculation Drill | IB与AQA计算机:计算题专项训练

📚 IB & AQA Computer Science Calculation Drill | IB与AQA计算机:计算题专项训练

Mastering calculation-based questions is key to excelling in IB and AQA Computer Science exams. This guide covers essential computational skills, from number systems and floating-point arithmetic to networking and algorithm analysis, with step-by-step examples.

掌握计算题对于IB和AQA计算机科学考试至关重要。本文涵盖核心计算技能,包括数制、浮点运算、网络和算法分析,并提供分步例题。


1. Number Base Conversions | 进制转换

Converting between binary, decimal, and hexadecimal is fundamental. Binary to decimal uses positional weights (powers of 2). Decimal to hex employs repeated division by 16, reading remainders backwards.

二进制、十进制和十六进制间的转换是基础。二进制转十进制使用位权(2的幂)。十进制转十六进制采用反复除以16,逆序读余数。

Example: convert 11010101₂ to decimal.

示例:将11010101₂转为十进制。

Step 1: Write place values 128, 64, 32, 16, 8, 4, 2, 1 under each bit.

步骤1:在每个二进制位下写出位值128, 64, 32, 16, 8, 4, 2, 1。

Step 2: Sum values where the bit is 1: 128 + 64 + 16 + 4 + 1 = 213₁₀.

步骤2:将位为1的位值相加:128 + 64 + 16 + 4 + 1 = 213₁₀。

Convert 200₁₀ to hex: 200 ÷ 16 = 12 remainder 8. 12 is C, so C8₁₆. In binary, C8₁₆ = 1100 1000₂.

将200₁₀转为十六进制:200 ÷ 16 = 12 余 8,12为C,得到C8₁₆。二进制为1100 1000₂。

128 64 32 16 8 4 2 1
1 1 0 1 0 1 0 1

Every hex digit maps to 4 bits, so conversions like 3F₁₆ = 0011 1111₂ are quick.

每个十六进制位对应4个二进制位,例如3F₁₆ = 0011 1111₂,转换快捷。


2. Binary Arithmetic & Two’s Complement | 二进制运算与补码

Addition follows column-wise carrying. For 1011₂ + 1101₂, align bits and add, carrying 1 when sum ≥ 2. The result is 11000₂ (24₁₀).

加法按位对齐进位。计算1011₂ + 1101₂,对应位相加,和≥2时进位,结果为11000₂ (24₁₀)。

Subtraction uses two’s complement. To compute 5 – 3 in 8-bit: 5 is 00000101, -3 is two’s complement of 00000011 → flip bits 11111100, add 1 → 11111101.

减法使用二补数。8位下计算5 – 3:5为00000101,-3是00000011的补码 → 各位取反11111100,加1得11111101。

Add: 00000101 + 11111101 = (1)00000010. Ignore the carry beyond 8 bits; result 00000010 = 2₁₀.

相加:00000101 + 11111101 = (1)00000010,忽略超出8位的进位,结果为00000010 = 2₁₀。

Overflow occurs when operands have same sign and the result’s sign differs. With 4-bit signed numbers: 0111 (7) + 0001 (1) = 1000 (-8), which is overflow.

溢出发生在操作数同号而结果异号时。4位有符号数:0111 (7) + 0001 (1) = 1000 (-8),发生溢出。

Key formula: -X = (2ⁿ – X) in n-bit two’s complement.

核心公式:n位补码下,-X = (2ⁿ – X)。


3. Floating-Point Representation | 浮点数表示

IEEE 754 single precision uses 32 bits: 1 sign bit, 8 exponent bits (bias 127), and 23 mantissa bits. Convert -13.75 to this format.

IEEE 754单精度使用32位:1位符号,8位指数(偏移127),23位尾数。将-13.75转为该格式。

Step 1: Sign bit = 1 for negative.

步骤1:负号,符号位 = 1。

Step 2: Write 13.75 in binary. 13₁₀ = 1101₂, 0.75×2=1.5→1, 0.5×2=1.0→1, so 0.75 = .11₂, giving 1101.11₂.

步骤2:写出13.75的二进制。13₁₀ = 1101₂,0.75×2=1.5取1,0.5×2=1.0取1,得.11₂,合为1101.11₂。

Step 3: Normalise to 1.10111 × 2³. True exponent = 3. Stored exponent = 3 + 127 = 130 = 10000010₂.

步骤3:规范化为1.10111 × 2³。真实指数 = 3,存储指数 = 3 + 127 = 130 = 10000010₂。

Step 4: Mantissa = 10111000000000000000000 (23 bits, drop the leading 1).

步骤4:尾数 = 10111000000000000000000(23位,去掉前面的1)。

Final representation: 1 10000010 10111000000000000000000.

最终表示:1 10000010 10111000000000000000000。

Decimal → binary fraction: multiply fractional part by 2 repeatedly, record integer parts.

十进制小数转二进制:反复乘2取整。


4. Logic Gates & Truth Tables | 逻辑门与真值表

Given a circuit: Y = (A AND B) OR (NOT C). Calculate Y for the inputs A=1, B=0, C=1.

给定电路:Y = (A AND B) OR (NOT C)。计算输入A=1, B=0, C=1时Y的值。

Step 1: A AND B = 1 AND 0 = 0.

步骤1:A AND B = 1 AND 0 = 0。

Step 2: NOT C = NOT 1 = 0.

步骤2:NOT C = NOT 1 = 0。

Step 3: 0 OR 0 = 0, so Y = 0.

步骤3:0 OR 0 = 0,因此Y = 0。

To build a full truth table, list all 2³ = 8 input combinations and evaluate stepwise. This skill is frequent in exam calculation tasks.

构建完整真值表需列出所有2³=8种输入组合并逐项求值。这种题型在考试计算中很常见。

You can also simplify expressions using Boolean algebra. For instance, A + A’B = A + B (absorption). Apply it to reduce gate counts.

也可用布尔代数化简表达式,例如 A + A’B = A + B(吸收律),用于减少门数。


5. Bitwise Operations & Masking | 位运算与掩码

Bitwise AND, OR, XOR, NOT, and shifts operate on individual bits. Apply mask 00001111 to byte 10110110 using AND.

按位与、或、异或、非以及移位操作针对单个位。对字节10110110应用掩码000

Published by TutorHao | IB 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