Binary System Crash Course for IB & CIE Computer Science | IB CIE 计算机:二进制 考点精讲

📚 Binary System Crash Course for IB & CIE Computer Science | IB CIE 计算机:二进制 考点精讲

Welcome to this comprehensive revision guide on binary systems for IB and CIE Computer Science. Whether you are preparing for an IB exam or a CIE paper, understanding how computers represent and manipulate numbers at the lowest level is absolutely essential. This article covers everything from basic conversion and arithmetic to two’s complement and floating-point representation, all tailored to the syllabus requirements of both examination boards.

欢迎阅读这篇针对 IB 和 CIE 计算机科学的二进制系统综合复习指南。无论你是在准备 IB 考试还是 CIE 考试,理解计算机如何在最底层表示和处理数字都是绝对必要的。本文涵盖了从基本转换和算术到二进制补码与浮点表示的所有内容,完全符合两种考试大纲的要求。

1. Why Binary? | 为什么使用二进制?

Computers use binary (base-2) because it maps perfectly onto the two-state nature of digital electronic circuits. A transistor or a memory cell can be in one of two reliable states: on or off, high voltage or low voltage, magnetised or not magnetised. These states represent the binary digits 1 and 0, enabling robust and noise-resistant storage and processing.

计算机使用二进制(基数为2)是因为它与数字电子电路的双稳态特性完美对应。晶体管或存储单元可以处于两种可靠状态之一:开或关、高电压或低电压、磁化或未磁化。这些状态分别代表二进制数字 1 和 0,从而实现可靠且抗噪声的存储与处理。

In the IB and CIE syllabus, you are expected to know that binary is the fundamental language of computers. All data – numbers, text, images, sound – ultimately break down into sequences of 1s and 0s. Understanding binary is the gateway to topics like data representation, logic gates, and machine-level programming.

在 IB 和 CIE 大纲中,你需要明白二进制是计算机的基本语言。所有数据——数字、文本、图像、声音——最终都分解为 1 和 0 的序列。理解二进制是通向数据表示、逻辑门和机器级编程等主题的大门。


2. Binary and Decimal Conversions | 二进制与十进制的转换

Binary to Decimal: Write the place values (powers of 2) from right to left, starting with 2⁰ = 1. Multiply each binary digit by its place value and sum the results. For example, the binary number 1101₂ equals (1×8) + (1×4) + (0×2) + (1×1) = 8 + 4 + 0 + 1 = 13 in decimal.

二进制转十进制:从右向左写出位值(2 的幂),从 2⁰ = 1 开始。将每个二进制位乘以其位值并求和。例如,二进制数 1101₂ 等于 (1×8) + (1×4) + (0×2) + (1×1) = 8 + 4 + 0 + 1 = 十进制 13。

Decimal to Binary: Repeatedly divide the decimal number by 2, recording the remainder each time. Read the remainders from bottom to top to get the binary equivalent. For decimal 13: 13 ÷ 2 = 6 remainder 1, 6 ÷ 2 = 3 remainder 0, 3 ÷ 2 = 1 remainder 1, 1 ÷ 2 = 0 remainder 1. Reading upwards gives 1101₂.

十进制转二进制:反复地将十进制数除以 2,每次记录余数。从下往上读取余数即可得到二进制数。以十进制 13 为例:13 ÷ 2 = 6 余 1,6 ÷ 2 = 3 余 0,3 ÷ 2 = 1 余 1,1 ÷ 2 = 0 余 1。从下往上读得到 1101₂。

Exam questions often ask for conversion between the two, and you must show clear working. Both IB and CIE mark schemes value steps – writing the place values or the division table is highly recommended.

考题经常要求两者之间的转换,你必须展示清晰的步骤。IB 和 CIE 的评分方案都看重过程——强烈建议写出位值表或除法表格。


3. Binary Addition | 二进制加法

Binary addition follows simple rules: 0+0=0, 0+1=1, 1+0=1, 1+1=0 with a carry of 1 to the next column, and 1+1+1 (including a carry) = 1 with a carry of 1. Let’s add 0110₂ (6) and 0101₂ (5):

二进制加法遵循简单的规则:0+0=0,0+1=1,1+0=1,1+1=0 并向下一列进位 1,1+1+1(包含进位)= 1 并向下一列进位 1。我们来计算 0110₂ (6) 加 0101₂ (5):

0110
+ 0101
——
1011 (which is 11 in decimal)

0110
+ 0101
——
1011(即十进制 11)

You should be comfortable adding two or more binary numbers. In the exam, align the bits properly and show carry bits. Always check the result by converting back to decimal.

你应该能熟练地相加两个或多个二进制数。在考试中,要对齐数位并标出进位。始终通过转换回十进制来检查结果。


4. Binary Subtraction via Two’s Complement | 通过二进制补码进行二进制减法

Instead of building a separate subtraction circuit, computers perform subtraction by adding the two’s complement of the subtrahend. The two’s complement of a binary number is found by inverting all bits (one’s complement) and then adding 1.

计算机不构建独立的减法电路,而是通过加上减数的二进制补码来执行减法。求一个二进制数的二进制补码的方法是:将所有位取反(反码),然后加 1。

Example: Subtract 5 (0101₂) from 9 (1001₂). Step 1: Find two’s complement of 0101₂. Invert: 1010₂; add 1: 1011₂. Step 2: Add 1001₂ + 1011₂ = 1 0100₂. Ignoring the extra carry-out (since we are working with 4 bits), we get 0100₂, which is 4 in decimal. 9 – 5 = 4.

示例:用 9 (1001₂) 减去 5 (0101₂)。步骤 1:求 0101₂ 的二进制补码。取反:1010₂;加 1:1011₂。步骤 2:将 1001₂ 与 1011₂ 相加 = 1 0100₂。忽略超出位(因为我们只使用 4 位),得到 0100₂,即十进制 4。9 – 5 = 4。

For CIE and IB, you must be able to carry out subtraction using two’s complement, including when the result is negative. This is a favourite topic in Paper 1.

对于 CIE 和 IB,你必须能够使用二进制补码进行减法,包括结果为负数的情况。这是卷一中最常见的考点之一。


5. Representing Negative Numbers: Sign-and-Magnitude vs Two’s Complement | 负数的表示:符号-数值表示法与二进制补码

Two common methods exist for representing signed integers: sign-and-magnitude and two’s complement. In sign-and-magnitude, the leftmost bit indicates the sign (0 for positive, 1 for negative) and the remaining bits hold the magnitude. For example, in 4 bits, +5 is 0101, and –5 is 1101. However, this causes two representations of zero (0000 and 1000) and complicates arithmetic.

表示有符号整数有两种常见方法:符号-数值表示法和二进制补码。在符号-数值表示法中,最左边的位表示符号(0 为正,1 为负),其余位表示数值大小。例如,在 4 位二进制中,+5 为 0101,–5 为 1101。然而,这会导致零有两种表示法(0000 和 1000),并使算术运算复杂化。

Two’s complement is the standard method used in modern computers. It overcomes the dual zero problem and allows subtraction to be performed by addition. In two’s complement, the most significant bit still indicates the sign, but its weight is negative. For an 8-bit number, bit 7 has a place value of –128 instead of +128.

二进制补码是现代计算机使用的标准方法。它克服了双零问题,并允许通过加法来实现减法。在二进制补码中,最高有效位仍然表示符号,但其权重为负。对于 8 位二进制数,第 7 位的位值是 –128 而不是 +128。

Binary (4-bit) Unsigned Two’s Complement
0000 0 0
0001 1 +1
… … …
0111 7 +7
1000 8 –8
1001 9 –7
… … …
1111 15 –1

In the exam, you must be able to determine the range of an n-bit two’s complement integer: from –2ⁿ⁻¹ to 2ⁿ⁻¹ – 1. For 8 bits, that’s –128 to +127.

考试中,你必须能够确定 n 位二进制补码整数的范围:–2ⁿ⁻¹ 到 2ⁿ⁻¹ – 1。对于 8 位二进制,即 –128 到 +127。


6. Binary Multiplication and Division | 二进制乘法和除法

Binary multiplication works just like decimal long multiplication: you multiply by each bit of the multiplier and shift the partial products left. For example, 101₂ (5) × 11₂ (3):

二进制乘法与十进制长乘法类似:将乘数每一位与被乘数相乘,然后将部分积左移。例如,101₂ (5) × 11₂ (3):

101
× 011
——
101 (101 × 1, no shift)
+ 1010 (101 × 1, shifted left one place)
+ 0000 (101 × 0, shifted left two places)
——
1111₂ (15 in decimal)

Binary division uses repeated subtraction and shifting, similar to long division. While less frequently examined in IB/CIE, understanding the similarity to decimal arithmetic helps solidify the concept that binary operations are not magical – they follow the same principles.

二进制除法使用重复减法和移位,类似于长除法。尽管在 IB/CIE 考试中较少直接考查,但理解与十进制算术的相似性有助于巩固一个概念:二进制运算并不神秘——它们遵循相同的原理。


7. Hexadecimal System | 十六进制系统

Hexadecimal (base-16) is a compact way to represent binary values. One hex digit represents four bits (a nibble), making it much easier for humans to read long binary strings. Hex digits range from 0 to 9 and then A (10) to F (15). For example, 1011 1101₂ can be written as BD₁₆.

十六进制(基数为16)是表示二进制值的一种紧凑方式。一个十六进制数字代表四个二进制位(半字节),这使人类更容易阅读长二进制串。十六进制数字范围从 0 到 9,然后是 A (10) 到 F (15)。例如,1011 1101₂ 可写作 BD₁₆。

Conversion between binary and hex is straightforward: group the binary number into groups of 4 bits starting from the right, then convert each group. To convert hex to binary, expand each hex digit into its 4-bit equivalent. Both IB and CIE require fluency in binary ↔ hex ↔ decimal conversions.

二进制与十六进制之间的转换很简单:将二进制数从右向左每 4 位分成一组,然后分别转换每组。要将十六进制转换为二进制,则将每个十六进制数字展开为其对应的 4 位二进制数。IB 和 CIE 都要求熟练掌握二进制 ↔ 十六进制 ↔ 十进制的转换。

Hexadecimal is also used to represent memory addresses, colour codes (e.g., in HTML/CSS), and MAC addresses. Examiners often include context-based questions linking hex to real-world computing.

十六进制还用于表示内存地址、颜色代码(如 HTML/CSS 中)和 MAC 地址。考官经常出一些联系实际的题目,将十六进制与实际计算关联起来。


8. Floating-Point Representation | 浮点数表示法

Real numbers (numbers with a fractional part) are stored in computers using floating-point representation, which is similar to scientific notation. A floating-point number consists of a mantissa (the significant digits) and an exponent (the power of the base). In binary, the base is 2. The value is: mantissa × 2exponent.

实数(带小数部分的数字)在计算机中使用浮点数表示法存储,这与科学记数法类似。一个浮点数由尾数(有效数字)和指数(基数的幂)组成。在二进制中,基数为 2。其值为:尾数 × 2指数。

In IB and CIE Computer Science, you must understand a simplified model: for a given number of bits allocated to mantissa and exponent, you can represent numbers in the form ±M × 2E. Normalisation is the process of adjusting the mantissa so that the most significant bit is non-zero (for positive numbers, it must be 1), which maximises precision.

在 IB 和 CIE 计算机科学中,你必须理解一个简化模型:在给定分配给尾数和指数的位数下,可以表示形式为 ±M × 2E 的数。规格化是调整尾数以使最高有效位非零(对于正数,必须为 1)的过程,这样可以最大化精度。

Example: Using a 12-bit register with an 8-bit mantissa (first bit sign) and a 4-bit exponent (first bit sign of the exponent, stored using two’s complement). The binary pattern might be: 0 1001100 0010. The mantissa sign bit 0 means positive. Mantissa bits: 1001100 (with an implied binary point after the sign bit, we get 0.1001100). Exponent 0010 is +2. Value = 0.1001100₂ × 2² = 10.01100₂ = 2 + 0.25 + 0.125 = 2.375 in decimal (after shifting).

示例:使用一个 12 位寄存器,其中 8 位尾数(首位为符号)和 4 位指数(首位为指数的符号,用二进制补码存储)。二进制模式可能为:0 1001100 0010。尾数符号位 0 表示正数。尾数位:1001100(隐含二进制小数点位于符号位之后,即 0.1001100)。指数 0010 即为 +2。值 = 0.1001100₂ × 2² = 10.01100₂ = 2 + 0.25 + 0.125 = 十进制 2.375(移位后)。


9. Normalisation in Detail | 规格化详解

Normalisation ensures a unique representation and avoids leading zeros. For a positive mantissa, the first bit after the sign bit should be 1. For example, 0.000101 × 2⁵ is not normalised; we shift the mantissa left and decrease the exponent: 0.101000 × 2². For a negative mantissa (using two’s complement), the first bit after the sign must be 0 (except for numbers like –0.5 which is normalised as 1.100…).

规格化确保表示方式的唯一性并避免前导零。对于正尾数,符号位后的第一位应为 1。例如,0.000101 × 2⁵ 不是规格化的;我们将尾数左移,同时减小指数:0.101000 × 2²。对于负尾数(使用二进制补码),符号位后的第一位必须是 0(除了像 –0.5 这样的数,其规格化形式为 1.100…)。

In exams, you may be given a floating-point bit pattern and asked to convert it to decimal or to normalise it. Practise shifting the mantissa and adjusting the exponent accordingly. Always keep in mind that the exponent is stored in two’s complement, so incrementing or decrementing it must obey the rules of signed arithmetic.

在考试中,考生可能会遇到一个浮点位模式,并被要求将其转换为十进制或进行规格化。请练习移动尾数并相应调整指数。始终牢记指数是以二进制补码形式存储的,因此对它进行加 1 或减 1 操作必须符合有符号算术的规则。


10. Range, Precision, Overflow and Underflow | 范围、精度、溢出与下溢

The range of a floating-point representation is determined by the number of exponent bits; the precision depends on the number of mantissa bits. More exponent bits mean a wider range; more mantissa bits mean finer precision. Overflow occurs when a number is too large to be represented (exponent too big positive). Underflow occurs when a number is too close to zero to be represented with normalised mantissa (exponent too big negative).

浮点表示的范围由指数位数决定;精度取决于尾数位数。指数位越多,范围越宽;尾数位越多,精度越高。当一个数的绝对值太大而无法表示(指数正得太多)时,就会发生溢出。当一个数的绝对值太接近零而无法以规格化尾数表示(指数负得太多)时,就会发生下溢。

Both IB and CIE want you to discuss the trade-off between range and precision in a fixed-size register. Given a total number of bits, increasing the exponent bits extends the range but reduces precision, and vice versa. This is a typical evaluation-style question.

IB 和 CIE 都要求你讨论在固定大小寄存器中范围与精度之间的权衡。在总位数给定的情况下,增加指数位可以扩大范围,但会降低精度,反之亦然。这是一道典型的评估类问题。


11. Common Pitfalls and Exam Tips | 常见易错点与考试技巧

Many students lose marks by omitting the working steps in conversion questions. Always show place-value tables or repeated-division remainders. In two’s complement subtraction, do not forget to handle the extra carry-out correctly: discard it if you are working within a fixed number of bits. When normalising a negative mantissa, remember that shifting should preserve the two’s complement pattern – your final mantissa must begin with ‘1.0’ for negatives (or be exactly 1.100… for –0.5).

许多学生因在转换题中遗漏解题步骤而失分。务必展示位值表或重复除法余数。在进行二进制补码减法时,不要忘记正确处理额外的进位输出:如果在固定位数内运算,则丢弃进位。在规格化负尾数时,请记住移位必须保持二进制补码模式——最终的尾数对于负数必须以 ‘1.0’ 开头(或者对于 –0.5 恰为 1.100…)。

  • Use ruled paper or draw columns for binary arithmetic — alignment prevents careless errors.
  • Double-check your answer by converting back to decimal.
  • In floating-point problems, identify the sign, mantissa, and exponent fields before calculating.
  • Practise past paper questions under timed conditions; speed and accuracy improve with repetition.
  • 使用方格纸或画出列来进行二进制算术运算——对齐可以防止粗心错误。
  • 通过转换回十进制来双重检查答案。
  • 在解浮点题时,先识别符号、尾数和指数字段再开始计算。
  • 在限时条件下练习往年真题;速度和准确性会随着反复练习而提高。

12. Summary and Final Thoughts | 总结与最后的思考

Binary is not just a theoretical topic – it is the foundation of all digital data storage and computation. Mastering binary conversions, two’s complement, and floating-point representation will not only earn you easy marks in Paper 1 but also deepen your understanding of computer architecture, memory, and system limitations. For IB students, these concepts connect directly to option topics like computer organisation; for CIE, they underpin many questions in both AS and A Level papers.

二进制不仅是一个理论话题——它是所有数字数据存储和计算的基础。掌握二进制转换、二进制补码和浮点表示法,不仅能让你在卷一轻松得分,还能加深你对计算机体系结构、内存和系统限制的理解。对于 IB 学生,这些概念直接连接到计算机组成等选修主题;对于 CIE,它们是 AS 和 A Level 试卷中许多题目的基础。

Remember to approach each problem systematically, show your working, and practise until the processes become second nature. Good luck with your exams!

请记住,系统化地处理每个问题,展示解题过程,并反复练习直至这些过程成为你的第二天性。祝你考试顺利!

Published by TutorHao | 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课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply

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

Exit mobile version