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

IB Computer Science: Binary Essentials | 二进制考点精讲

2026-07-13 22:46 · 本文部分内容由AI辅助创作

📚 IB Computer Science: Binary Essentials | 二进制考点精讲

Binary is the fundamental language of computers. In IB Computer Science, understanding binary representation, arithmetic, negative number encoding (sign and magnitude, two's complement), hexadecimal, floating-point numbers and logical operations is essential for scoring well on Paper 1 and Paper 2. This revision guide keeps every core point of the original notes and expands it into a complete, exam-focused walkthrough with clear explanations, worked examples, tables and common pitfalls.

二进制是计算机的基础语言。在 IB 计算机科学中,理解二进制表示、算术运算、负数编码(符号-数值法与二进制补码)、十六进制、浮点数以及逻辑运算,是 Paper 1 和 Paper 2 拿高分的关键。这篇考点精讲保留原有全部信息点,并扩写成完整、紧扣考纲的复习指南,配有清晰的解释、例题、表格与常见易错点。

1. What is Binary? | 什么是二进制?

A binary number system uses only two digits: 0 and 1. Each digit is called a bit (binary digit). Computers use binary because digital circuits have two stable states (on/off), which are naturally represented by 1 and 0. A group of 8 bits forms a byte, which is the basic unit of storage in computing.

二进制数字系统只使用两个数字:0 和 1。每个数字称为一个二进制位(bit)。计算机使用二进制,是因为数字电路只有两种稳定状态(开/关),天然用 1 和 0 表示。8 个位组成一个字节(byte),这是计算机存储的基本单位。

In a positional (place-value) system, each position represents a power of two. The rightmost bit is the least significant bit (LSB, 2⁰) and the leftmost bit is the most significant bit (MSB). For example, the binary number 1101₂ is calculated as shown below.

在二进制位值系统中,每一位代表 2 的幂次。最右边的位是最低有效位(LSB,2⁰),最左边的位是最高有效位(MSB)。例如,二进制数 1101₂ 的计算如下。

1101₂ = 1×2³ + 1×2² + 0×2¹ + 1×2⁰ = 8 + 4 + 0 + 1 = 13₁₀

The table below lists the place value of each bit in one byte. Memorising 128, 64, 32, 16, 8, 4, 2, 1 makes almost every conversion question faster and less error-prone.

下表列出了一个字节中每位的位值。熟记 128、64、32、16、8、4、2、1,能让几乎所有转换题更快、更不易出错。

Bit position 7 6 5 4 3 2 1 0
Power of 2 2⁷ 2⁶ 2⁵ 2⁴ 2³ 2² 2¹ 2⁰
Value 128 64 32 16 8 4 2 1

2. Binary to Decimal Conversion | 二进制转十进制

To convert a binary integer to decimal, multiply each bit by its place value (a power of two) and add the results. Only the positions holding a 1 contribute to the total, so a quick approach is to simply add up the place values of all the 1s.

要将二进制整数转为十进制,把每一位乘以其位值(2 的幂),然后把结果相加。只有值为 1 的位置对总和有贡献,因此更快的做法是直接把所有 1 所对应的位值相加。

esent negative powers of two: 2⁻¹ = 0.5, 2⁻² = 0.25, 2⁻³ = 0.125, 2⁻⁴ = 0.0625, and so on.

对于带小数的二进制数,二进制小数点后的位表示 2 的负幂:2⁻¹ = 0.5,2⁻² = 0.25,2⁻³ = 0.125,2⁻⁴ = 0.0625,依此类推。

Example: 011₂ = 11₁₀ and the fractional part .01₂ = 0×2⁻¹ + 1×2⁻² = 0.25₁₀, then add them together.

示例:把 1011.01₂ 转为十进制。将数拆成整数部分 1011₂ = 11₁₀ 和小数部分 .01₂ = 0×2⁻¹ + 1×2⁻² = 0.25₁₀,然后相加。

1011.01₂ = (8 + 0 + 2 + 1) + (0 + 0.25) = 11.25₁₀

Always write the final answer with the base as a subscript (11.25₁₀) and show your working line by line. In IB mark schemes, the place values you write down often earn method marks even if the final total is wrong.

答案一定要带上底数下标(11.25₁₀),并逐行写出过程。在 IB 评分标准中,即使最终结果算错,写出的位值展开也常常能拿到过程分。


3. Decimal to Binary Conversion | 十进制转二进制

For a decimal integer, use repeated division by 2: divide the number by 2, record the remainder (0 or 1), then divide the quotient by 2 again, and continue until the quotient is 0. Finally, read the remainders from bottom to top.

对于十进制整数,使用"反复除以 2"法:把数除以 2,记录余数(0 或 1),再用商除以 2,如此继续直到商为 0。最后把余数从下往上读,即为结果。

Example: Convert 45₁₀ to binary.

示例:把 45₁₀ 转为二进制。

广告 / Sponsored

Reading remainders upward: 45₁₀ = 101101₂ (verify: 32 + 8 + 4 + 1 = 45)

For the fractional part, use repeated multiplication by 2: multiply the fraction by 2, take the integer part (0 or 1) as the next bit, keep the remaining fraction, and repeat. Stop when the fraction becomes 0 or when you reach the required number of bits.

对于小数部分,使用"反复乘以 2"法:把小数乘以 2,取整数部分(0 或 1)作为下一位,保留剩余小数继续重复。当小数部分变为 0,或达到题目要求的位数时停止。

Example: ; 0.75 × 2 = 1.5 → 1; 0.5 × 2 = 1.0 → 1. Reading the integer parts downward gives 0.1011₂.

示例:把 0.6875₁₀ 转为二进制:0.6875 × 2 = 1.375 → 1;0.375 × 2 = 0.75 → 0;0.75 × 2 = 1.5 → 1;0.5 × 2 = 1.0 → 1。把整数部分从上往下读,得到 0.1011₂。


4. Binary Addition, Subtraction and Overflow | 二进制加减法与溢出

= 10 (write 0 and carry 1). When three 1s are added, 1 + 1 + 1 = 11 (write 1 and carry 1).

二进制加法遵循四条基本规则:0 + 0 = 0,0 + 1 = 1,1 + 0 = 1,1 + 1 = 10(本位写 0,进位 1)。当三个 1 相加时,1 + 1 + 1 = 11(本位写 1,进位 1)。

Example: by-column calculation produces a carry out of the most significant bit, giving a 5-bit result.

示例:1011₂ + 0110₂ = 10001₂,用十进制验算 11 + 6 = 17 成立。逐列相加时,最高有效位会产生一个进位,得到 5 位结果。

Subtraction is normally performed by adding the two's complement of the subtrahend, because digital circuits are built to add rather than subtract. Any final carry out of the leftmost bit is discarded in fixed-width two's complement arithmetic.

减法通常通过加上减数的二进制补码来完成,因为数字电路是为"加"而不是"减"设计的。在定长二进制补码运算中,最左位产生的最终进位会被丢弃。

Example: 1011₂ − 0110₂ in 4 bits. The two' 10101, discard the leading carry, and the result is 0101₂ = 5₁₀, which matches 11 − 6 = 5.

示例:4 位下计算 1011₂ − 0110₂。0110 的二进制补码是 1010(0110 取反得 1001,再加 1)。因此 1011 + 1010 = 10101,丢弃最高进位,结果为 0101₂ = 5₁₀,与 11 − 6 = 5 相符。

Overflow occurs when the result of an arithmetic operation cannot be represented in the fixed number of bits available. Using two's complement, overflow happens when two positive numbers produce a negative result, or two negative numbers produce a positive result. The standard test is that the carry into the MSB differs from the carry out of the MSB.

溢出是指算术运算的结果无法用固定的位数表示。在二进制补码下,溢出发生在两个正数相加得到负数、或两个负数相加得到正数的时候。标准判别方法是:进入 MSB 的进位与从 MSB 出去的进位不相同。


5. Representing Negative Numbers | 负数的表示

There are two encoding schemes you must know: sign and magnitude, and two' ore the magnitude. Its weakness is that it has two representations of zero: 0000 0000 (+0) and 1000 0000 (−0).

你必须掌握两种编码方案:符号-数值法与二进制补码。在符号-数值法中,MSB 是符号位(0 表示正,1 表示负),其余位存放数值大小。它的缺点是存在两个零:0000 0000(+0)和 1000 0000(−0)。

In two's complement, a negative number is produced by inverting all the bits of the positive number and adding 1. Equivalently, the MSB carries a negative weight of −2ⁿ⁻¹, so the MSB is still a sign indicator, but only one zero exists.

在二进制补码中,将正数按位取反再加 1,就得到对应的负数。等价地说,MSB 的权值是 −2ⁿ⁻¹,所以 MSB 依然是符号标志,但零只有唯一一种表示。

Example: Represent −5 in 8-bit two' 11 1010; add 1 → 1111 1011. Check with place values: −128 + 64 + 32 + 16 + 8 + 2 + 1 = −5.

示例:用 8 位二进制补码表示 −5。5 = 0000 0101;取反得 1111 1010;加 1 得 1111 1011。用位值验算:−128 + 64 + 32 + 16 + 8 + 2 + 1 = −5。

4-bit pattern Unsigned value Sign and magnitude Two's complement
0000 0 +0 0
0101 5 +5 5
1011 11 −3 −5
1111 15 −7 −1

6. Hexadecimal and Why It Matters | 十六进制及其意义

r bits map to one hexadecimal digit, which makes conversion between binary and hexadecimal

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

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

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