← 返回资讯屏轩教育 · 行业资讯

IB & OCR Computer Science: Formula Summary Handbook | IB 与 OCR 计算机科学:公式汇总手册

2026-07-14 23:32 · 本文部分内容由AI辅助创作

📚 IB & OCR Computer Science: Formula Summary Handbook | IB 与 OCR 计算机科学:公式汇总手册

This handbook brings together the most essential formulas and computational methods required for the IB Diploma Computer Science and OCR A Level Computer Science specifications. Whether you are calculating file sizes, assessing algorithm efficiency, or simplifying Boolean expressions, these core equations will support your revision and problem-solving in both theory and practical examinations.

本手册汇集了 IB 文凭计算机科学和 OCR A Level 计算机科学考试中最关键的公式与计算方法。无论是计算文件大小、评估算法效率,还是化简布尔表达式,这些核心公式都将帮助你在理论与实操考试中有效地复习和解题。


1. Bits, Bytes and Storage Units | 位、字节与存储单位

All digital data is represented using binary digits (bits). A group of 8 bits makes one byte, which is the smallest addressable unit in most computer architectures. Storage capacity is expressed in multiples of bytes, and it is important to recognise both the binary (IEC) and decimal (SI) definitions that appear in exam questions.

所有数字数据都使用二进制位 (bit) 表示。8 个位组成一个字节 (byte),这是大多数计算机体系结构中最小的可寻址单元。存储容量用字节的倍数表示,考试中常需要区分二进制 (IEC) 和十进制 (SI) 两种定义。

The base conversion is simple:

基本转换很简单:

1 Byte = 8 bits

Common units are built on this foundation:

常见单位以此为基础构建:

UnitBinary (bytes)Decimal (bytes)
1 KiB / 1 kB2¹⁰ = 1024 bytes10³ = 1000 bytes
1 MiB / 1 MB1024 KiB = 1,048,576 bytes1000 kB = 1,000,000 bytes
1 GiB / 1 GB1024 MiB = 1,073,741,824 bytes1000 MB = 1,000,000,000 bytes
1 TiB / 1 TB1024 GiB = 2⁴⁰ bytes1000 GB = 10¹² bytes

In general, binary units (KiB, MiB, etc.) are used for RAM and cache memory, while decimal units (kB, MB) are used by storage manufacturers and in network transmission. Always check the context of the question to decide which multiplier applies.

通常,二进制单位 (KiB、MiB 等) 用于内存和缓存,而存储制造商和网络传输则使用十进制单位 (kB、MB)。做题时请一定根据题意判断应该使用哪种倍数。


2. Text File Size | 文本文件大小

The size of a plain text file depends on the character encoding scheme and the number of characters. Each character consumes a fixed or variable number of bits. For straightforward calculations, ASCII typically uses 8 bits (extended ASCII) or 7 bits (original), while Unicode UTF-32 uses 32 bits per character.

纯文本文件的大小取决于字符编码方案和字符数量。每个字符占用固定或可变的位数。在直接计算中,ASCII 通常使用 8 位 (扩展 ASCII) 或 7 位 (原版),而 Unicode UTF-32 每个字符使用 32 位。

Text file size (bits) = Number of characters × Bits per character

Text file size (bytes) = (Number of characters × Bits per character) / 8

For example, a document containing 2000 characters encoded in 8‑bit ASCII uses 2000 × 8 = 16,000 bits or 2000 bytes. If UTF‑32 is used, the same text would require 2000 × 32 = 64,000 bits (8000 bytes).

例如,一份包含 2000 个字符、采用 8 位 ASCII 编码的文档需 2000 × 8 = 16,000 位,即 2000 字节。若采用 UTF‑32,相同文本则需要 2000 × 32 = 64,000 位 (8000 字节)。


3. Image File Size | 图像文件大小

Bitmap image size is determined by the image dimensions (width and height in pixels) and the colour depth, which measures how many bits are used to represent the colour of each pixel. A higher colour depth allows more distinct colours but increases the file size.

位图图像大小由图像尺寸 (以像素为单位的宽度与高度) 和颜色深度决定,颜色深度表示每个像素用多少位来表示颜色。更高的颜色深度允许更精细的颜色,但也会增大文件体积。

Image size (bits) = Width (pixels) × Height (pixels) × Colour depth (bpp)

Image size (bytes) = (Width × Height × Colour depth) / 8

If metadata is excluded, an uncompressed 1024×768 image with 24‑bit colour (true colour) would be 1024 × 768 × 24 = 18,874,368 bits, which equals 2,359,296 bytes ≈ 2.25 MiB. For a black‑and‑white image with 1‑bit colour depth, the same dimensions give only about 98,304 bytes.

忽略元数据时,一张未压缩的 1024×768、24 位真彩色图像大小为 1024 × 768 × 24 = 18,874,368 位,即约 2,359,296 字节 ≈ 2.25 MiB。同样尺寸的黑白图像 (1 位色深) 则仅约 98,304 字节。


4. Sound File Size | 音频文件大小

Digital sound is captured by sampling an analogue signal at regular intervals. Each sample is stored with a specific bit depth, and the total file size is a product of the sample rate, bit depth, duration and the number of channels (1 for mono, 2 for stereo).

数字音频通过对模拟信号进行等间隔采样获得。每个样本以特定的位深度存储,文件总大小是采样率、位深度、时长与声道数 (单声道为 1,立体声为 2) 的乘积。

Sound file size (bits) = Sample rate (Hz) × Bit depth × Duration (s) × Channels

Sound file size (bytes) = (Sample rate × Bit depth × Duration × Channels) / 8

For instance, a 3‑minute (180 s) stereo CD‑quality recording sampled at 44,100 Hz with 16‑bit depth yields 44,100 × 16 × 180 × 2 ≈ 254,016,000 bits, roughly 30.28 MiB. Reducing the sample rate or bit depth directly shrinks the uncompressed file.

例如,一段 3 分钟 (180 秒) 的立体声 CD 质量录音 (采样率 44,100 Hz,位深度 16 位) 的大小为 44,100 × 16 × 180 × 2 ≈ 254,016,000 位,约合 30.28 MiB。降低采样率或位深度会直接减小未压缩文件的大小。


广告 / Sponsored

5. Data Transfer Time and Bandwidth | 数据传输时间与带宽

When a file is transmitted over a network or read from storage, the time required depends on the size of the file and the transfer rate (bandwidth). It is essential to express both the file size and the transfer rate in the same unit, usually bits.

当文件通过网络传输或从存储器读取时,所需时间取决于文件大小和传输速率 (带宽)。关键是要将文件大小和传输速率转换为相同单位,通常使用位 (bit)。

Transfer time (s) = File size (bits) / Bandwidth (bps)

File size (bits) = File size (bytes) × 8

If a 500 MB file (decimal) is downloaded over a 100 Mbps connection, first convert everything to bits: 500 × 10⁶ × 8 = 4 × 10⁹ bits. Then time = 4 × 10⁹ / (100 × 10⁶) = 40 seconds. In reality, protocol overheads and network conditions will increase this value.

如果通过 100 Mbps 的连接下载一个 500 MB 文件 (十进制),先将全部转为位:500 × 10⁶ × 8 = 4 × 10⁹ 位。时间 = 4 × 10⁹ / (100 × 10⁶) = 40 秒。实际中,协议开销和网络状况会使所需时间更长。


6. Compression Ratio | 压缩比

Compression reduces the number of bits needed to represent data. The compression ratio expresses the relationship between the original (uncompressed) size and the compressed size. A higher ratio indicates more aggressive compression, though lossy compression usually achieves far higher ratios than lossless techniques.

压缩可以减少表示数据所需的位数。压缩比表示原始 (未压缩) 大小与压缩后大小之间的关系。比值越高,压缩越激进,尽管有损压缩通常比无损技术能达到远更高的压缩比。

Compression ratio = Original size / Compressed size

It may also be written as a ratio like Original : Compressed. For example, a 200 MB video that is compressed to 40 MB has a ratio of 200 / 40 = 5, often stated as 5:1. The space saving percentage can be calculated as (1 – Compressed/Original) × 100 %.

它也可以表示为诸如 原始大小 : 压缩后大小 的形式。例如,一个 200 MB 的视频被压缩至 40 MB,压缩比为 200 / 40 = 5,常写作 5:1。节省空间的百分比可用 (1 – 压缩后大小/原始大小) × 100 % 计算。


7. Binary Arithmetic and Overflow | 二进制运算与溢出

Addition in binary uses the same principles as decimal addition, but overflow must be watched carefully when using a fixed number of bits. In two's complement representation, overflow occurs when the sum of two numbers with the same sign yields a result with a different sign.

二进制加法与十进制加法原理相同,但在固定位数下必须留意溢出。在二进制补码表示中,当两个同号数相加得到异号结果时即发生溢出。

Range of n‑bit two's complement: –2ⁿ⁻¹ to 2ⁿ⁻¹ – 1

The total number of distinguishable values in n bits is always 2ⁿ. For example, with 8 bits the integer range is –128 to +127. An attempt to store 127 + 1 would produce –128 in 8‑bit two's complement, which is a classic overflow condition. Carry into but not out of the most significant bit also signals overflow.

n 位可区分的值的总数总是 2ⁿ。例如,8 位整数范围为 –128 到 +127。若尝试储存 127 + 1,在 8 位补码中会得到 –128,这正是典型的溢出状况。最高位有进位输入但无进位输出同样是溢出的标志。


8. Boolean Algebra Laws and Simplification | 布尔代数定律与化简

Boolean algebra governs the operations on TRUE and FALSE values implemented by logic gates. Understanding the key laws allows you to simplify circuit expressions, reduce the number of gates, and write more efficient code for logical conditions.

布尔代数控制着由逻辑门实现的 TRUE 和 FALSE 值上的运算。理解关键定律可以帮助你化简电路表达式、减少逻辑门数量,并为逻辑条件编写更高效的代码。

Commutative: A + B = B + A    A · B = B · A

Associative: (A + B) + C = A + (B + C)

Distributive: A · (B + C) = A · B + A · C

De Morgan: (A + B)' = A' · B'    (A · B)' = A' + B'

Absorption: A + A · B = A    A · (A + B) = A

Other useful identities include A + 0 = A, A · 1 = A, A + A' = 1 and A · A' = 0. When simplifying logic circuits or truth tables, systematically applying these identities helps minimise the sum-of-products form.

其他有用恒等式包括 A + 0 = A、A · 1 = A、A + A' = 1 以及 A · A' = 0。在化简逻辑电路或真值表时,系统性地应用这些恒等式有助于最小化“积之和”表达式。


9. CPU Performance Metrics | CPU 性能指标

The performance of a central processing unit is often evaluated through clock speed, execution time, and throughput metrics. These measures help compare different processors and understand how architectural choices affect program execution.

中央处理器的性能通常通过时钟速度、执行时间和吞吐量指标来评估。这些指标有助于比较不同的处理器,并理解体系结构选择如何影响程序执行。

Clock cycle time = 1 / Clock frequency

CPU execution time = Clock cycles / Clock frequency

CPI = Total clock cycles / Instruction count

MIPS = Instruction count / (Execution time × 10⁶)

If a processor runs at 2 GHz and a program requires 4 × 10⁹ clock cycles,

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

广告 / Sponsored
IBDP国际文凭计算机科学学生用书 高级及标准水平 Computer Science for the IB Diplo…
计算机 备考教辅 · 正版现货 · 与本文内容相关
查看详情 / View on Taobao参考价 ¥524.0

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

备考资讯每日更新,关注不错过
考纲变化 · 科目分析 · 学习方法
扫码关注公众号 tutorhao
在微信里长按二维码识别关注
或截图后用「扫一扫 → 相册」选择本图
公众号:tutorhao