Binary Essentials for A-Level Edexcel Computer Science | A-Level Edexcel 计算机:二进制 考点精讲

📚 Binary Essentials for A-Level Edexcel Computer Science | A-Level Edexcel 计算机:二进制 考点精讲

Binary is the foundation of all modern computing systems. Understanding how data is represented and manipulated at the binary level is crucial for A-Level Computer Science, as it underpins topics ranging from data storage and arithmetic to machine-level instructions and error detection. This revision guide covers all essential binary concepts required by the Edexcel specification, breaking them down into clear, exam-focused sections.

二进制是所有现代计算系统的基石。理解数据如何在二进制层面表示和操作,对于 A-Level 计算机科学至关重要,因为它支撑着从数据存储、算术运算到机器级指令和错误检测等多个主题。本复习指南涵盖了 Edexcel 考试大纲要求的所有核心二进制概念,并将其分解为清晰、聚焦考点的各个部分。

1. Number Bases and Binary Representation | 数制与二进制表示

All digital computers use the binary (base-2) number system, which uses only two digits: 0 and 1. Every piece of data, whether a number, character, or instruction, is ultimately stored as a sequence of bits. A single binary digit is called a bit, and a group of 8 bits forms a byte. Larger units include the kilobyte (1024 bytes), megabyte, gigabyte, and terabyte, which are often used to quantify memory and storage capacity.

所有的数字计算机都使用二进制(基数为2)的数制,它只使用两个数码:0 和 1。每一份数据,无论是数字、字符还是指令,最终都以比特 (bit) 序列的形式存储。单个二进制位称为一个比特,8 个比特组成一个字节 (byte)。更大的单位包括千字节 (1024 字节)、兆字节、吉字节和太字节,它们常用来表示内存和存储容量。

The value of each bit depends on its position, with the rightmost bit representing 2⁰ = 1, the next 2¹ = 2, then 2² = 4, and so on. This positional notation allows binary numbers to represent any unsigned integer by summing the contributions of bits that are set to 1. For example, the binary number 1011₂ equals 1×8 + 0×4 + 1×2 + 1×1 = 11 in decimal.

每个比特的值取决于它的位置,最右边的位代表 2⁰ = 1,接下来是 2¹ = 2,然后是 2² = 4,依此类推。这种位权记数法使得二进制数可以通过将值为 1 的位所代表的权值相加来表示任何无符号整数。例如,二进制数 1011₂ 等于 1×8 + 0×4 + 1×2 + 1×1 = 11(十进制)。


2. Converting Between Binary, Decimal, and Hexadecimal | 二进制、十进制与十六进制互转

Conversion between number bases is a fundamental skill. To convert from binary to decimal, you multiply each bit by its corresponding power of two and add the results. For instance, 1101₂ = 1×8 + 1×4 + 0×2 + 1×1 = 13₁₀. To convert decimal to binary, repeatedly divide the decimal number by 2 and record the remainders, reading them in reverse order to obtain the binary equivalent.

不同进制之间的转换是一项基本技能。从二进制转换到十进制,需要将每一位与对应的 2 的幂相乘并求和。例如,1101₂ = 1×8 + 1×4 + 0×2 + 1×1 = 13₁₀。从十进制转换到二进制,可以采用重复除以 2 并记录余数的方法,逆序读取余数即可得到二进制结果。

Hexadecimal (base-16) is widely used in computing as a more compact way to represent binary values. Each hex digit represents four binary digits (a nibble). The digits 0–9 represent themselves, while A–F stand for 10–15. To convert binary to hexadecimal, split the binary number into groups of four bits from the right, then replace each group with its hex equivalent. For example, 10111010₂ becomes BA₁₆ (since 1011 = B, 1010 = A). Converting hexadecimal to binary simply reverses this process.

十六进制(基数为16)在计算中广泛使用,因为它能够更紧凑地表示二进制值。每个十六进制位代表四个二进制位(一个半字节)。数字 0–9 表示自身,而 A–F 代表 10–15。将二进制转换为十六进制时,从右向左每四位一组进行划分,然后将每组替换为对应的十六进制数字。例如,10111010₂ 变成 BA₁₆(因为 1011 = B,1010 = A)。从十六进制转换到二进制只需反向操作。


3. Binary Arithmetic | 二进制算术运算

Addition in binary follows rules similar to decimal addition but with only 0 and 1: 0+0=0, 0+1=1, 1+0=1, and 1+1=0 with a carry of 1 to the next column. When adding two multi-bit numbers, carries propagate leftwards. Subtraction can be performed directly or by converting the subtrahend to its two’s complement and adding.

二进制的加法规则与十进制加法类似,但仅涉及 0 和 1:0+0=0,0+1=1,1+0=1,1+1=0 并向高位进位 1。当相加两个多位二进制数时,进位会向左传播。减法可以直接执行,也可以通过将减数转换为其补码后相加来实现。

Binary multiplication is simpler than decimal: it is a series of shifts and additions. For each bit of the multiplier, you shift the multiplicand left and add if the bit is 1. Division can be carried out by repeated subtraction and shifting. In A-Level exams, you may be expected to perform these operations with small numbers or demonstrate an understanding of the algorithms.

二进制乘法比十进制乘法更简单,它是一系列移位和加法的组合。对于乘数的每一位,将被乘数左移,若该位为 1 则相加。除法可以通过重复减法和移位来完成。在 A-Level 考试中,你可能需要用小数字执行这些运算,或展示对算法的理解。


4. Two’s Complement for Negative Numbers | 补码表示负数

Two’s complement is the standard method for representing signed integers in binary. In an n-bit system, the most significant bit (MSB) has a negative weight of -2ⁿ⁻¹, while all other bits have positive weights. This allows both positive and negative numbers to be stored using the same hardware for addition and subtraction without needing separate sign handling.

补码是二进制表示带符号整数的标准方法。在 n 位系统中,最高有效位 (MSB) 的权值为负的 -2ⁿ⁻¹,而其余各位保持正的权值。这使得正数和负数可以使用相同的硬件进行加法和减法运算,无需单独处理符号。

To obtain the two’s complement representation of a negative number, start with the binary of its absolute value, invert all bits (one’s complement), and then add 1. For example, to represent -5 in 4 bits: +5 is 0101; invert to 1010; add 1 to get 1011. Thus, 1011 is -5 in two’s complement. The range of representable numbers in n bits is from -2ⁿ⁻¹ to 2ⁿ⁻¹ – 1. Overflow occurs when the result of an operation falls outside this range, which can be detected by checking if the carry into the sign bit differs from the carry out.

要想得到负数的补码表示,首先写出其绝对值的二进制,然后对所有位取反(反码),最后加 1。例如,用 4 位表示 -5:+5 为 0101;取反得 1010;加 1 得 1011。因此,1011 就是 -5 的补码形式。n 位补码可表示的数值范围从 -2ⁿ⁻¹ 到 2ⁿ⁻¹ – 1。当运算结果超出此范围时,会发生溢出,可以通过检查进入符号位的进位与离开符号位的进位是否不同来检测。


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

Real numbers are stored in binary using floating-point representation, which consists of a sign bit, an exponent, and a mantissa (also called the significand). The value is given by: (-1)ˢⁱᵍⁿ × mantissa × 2ᵉˣᵖᵒⁿᵉⁿᵗ. The mantissa is usually normalised so that its first bit is 1 (for non-zero numbers), maximising precision. The exponent is often stored in biased form to handle negative exponents without a sign bit.

实数在二进制中使用浮点数表示法存储,它由符号位、指数和尾数(也称为有效数字)组成。值由这个公式给出:(-1)ˢⁱᵍⁿ × 尾数 × 2ᵉˣᵖᵒⁿᵉⁿᵗ。尾数通常经过规格化,使其第一位为 1(对于非零数),以最大化精度。指数常以移码(偏置形式)存储,以便在不使用符号位的情况下处理负指数。

Edexcel questions typically ask you to convert between binary floating-point and decimal, adjust the binary point, normalise numbers, or discuss the trade-off between range and precision. Increasing the exponent bits increases the range but reduces the mantissa bits, thus lowering precision. Floating-point arithmetic can introduce rounding errors because not all decimal fractions can be represented exactly in binary.

Edexcel 的考题通常要求你在二进制浮点数和十进制之间进行转换,调整二进制小数点,对数字进行规格化,或者讨论范围与精度之间的权衡。增加指数位可以扩大表示范围,但会减少尾数位,从而降低精度。浮点运算可能引入舍入误差,因为并非所有十进制小数都能在二进制中被精确表示。


6. Bitwise Operations and Logical Shifts | 位运算与逻辑移位

Bitwise operators act on the individual bits of binary strings. The basic operations include NOT (inverts each bit), AND (outputs 1 only if both inputs are 1), OR (outputs 1 if at least one input is 1), and XOR (outputs 1 if the inputs differ). These operations are used in masking, setting or clearing specific bits, and in encryption algorithms.

位运算符作用于二进制串的各个位。基本操作包括 NOT(将每一位取反)、AND(仅当两个输入位都为 1 时输出 1)、OR(至少有一个输入为 1 时输出 1)和 XOR(当输入位不同时输出 1)。这些操作被用在掩码、设置或清除指定位以及加密算法中。

A logical shift moves all bits left or right by a specified number of positions, filling the vacated positions with zeros. A left logical shift by one place multiplies an unsigned binary number by 2; a right logical shift divides by 2 (ignoring remainders). Logical shifts treat the number as unsigned; thus, they do not preserve the sign of a signed number.

逻辑移位将所有位向左或向右移动指定的位数,空出的位用 0 填充。向左逻辑移一位相当于将无符号二进制数乘以 2;向右逻辑移一位相当于除以 2(忽略余数)。逻辑移位将数字视为无符号数,因此它不会保留带符号数的符号位。


7. Arithmetic Shifts and Multiplication/Division | 算术移位与乘除

An arithmetic shift is used for signed two’s complement numbers. In an arithmetic right shift, the sign bit (MSB) is replicated into the vacated positions to preserve the sign of the number. This operation correctly divides a signed number by 2, rounding towards negative infinity. An arithmetic left shift behaves identically to a logical left shift, but it can cause overflow if the sign bit changes.

算术移位用于带符号的补码数。在算术右移中,符号位 (MSB) 被复制到空出的位置,以保持数的符号。该操作能将带符号数正确除以 2,并向负无穷方向舍入。算术左移与逻辑左移行为相同,但如果符号位发生改变,则可能导致溢出。

Understanding the difference between logical and arithmetic shifts is important when dealing with integer arithmetic and bit manipulation in low-level programming. Exam questions may ask you to identify which shift operation is appropriate for a given context and to predict the result of a shift on a particular bit pattern.

在进行低级编程的整数算术和位操作时,理解逻辑移位和算术移位的区别非常重要。考题可能会让你根据给定情境判断应使用哪种移位,并预测特定二进制模式的移位结果。


8. Binary-Coded Decimal (BCD) | 二-十进制编码(BCD)

Binary-Coded Decimal represents each decimal digit as a 4-bit binary code. For example, the decimal number 25 is represented as 0010 0101 in BCD, whereas its pure binary equivalent is 11001₂. BCD simplifies the conversion for human-readable displays and avoids the rounding errors that can occur when converting decimal fractions to binary, making it useful in financial and measurement systems.

二-十进制编码将每个十进制位用 4 位二进制编码表示。例如,十进制数 25 在 BCD 中表示为 0010 0101,而其纯二进制形式为 11001₂。BCD 简化了面向人类可读显示的转换过程,并避免了将十进制小数转为二进制时可能出现的舍入误差,因此在金融和测量系统中很有用。

However, BCD is less storage-efficient than pure binary because some 4-bit combinations (1010 to 1111) are wasted. Arithmetic in BCD requires special adjustment after binary addition, typically by adding 6 to any nibble that exceeds 9. The Edexcel specification expects you to be able to convert between BCD and decimal, and to understand its advantages and limitations.

然而,BCD 的存储效率低于纯二进制,因为部分 4 位组合(1010 至 1111)被浪费了。BCD 的算术运算在二进制加法后需要进行特殊调整,通常是对任何超过 9 的半字节加 6。Edexcel 大纲要求你能在 BCD 和十进制之间进行转换,并理解其优点和局限性。


9. ASCII and Unicode in Binary | ASCII与Unicode的二进制编码

Characters are encoded as binary numbers using standard codes. The American Standard Code for Information Interchange (ASCII) uses 7 bits to represent 128 characters, including English letters, digits, punctuation, and control codes. Extended ASCII uses 8 bits, allowing 256 characters, which covers additional symbols and accented letters. In binary, the letter ‘A’ is 1000001 in 7-bit ASCII.

字符使用标准编码以二进制数的形式存储。美国信息交换标准代码(ASCII)使用 7 位表示 128 个字符,包括英文字母、数字、标点符号和控制码。扩展 ASCII 使用 8 位,可表示 256 个字符,涵盖了额外的符号和带重音字母。在二进制中,字母 “A” 在 7 位 ASCII 中表示为 1000001。

Unicode was developed to support characters from all writing systems worldwide. It can use up to 32 bits per character, though common encodings like UTF-8 use a variable number of bytes to maintain compatibility with ASCII while encoding a vast range of characters. The main advantage of Unicode over ASCII is its comprehensive multilingual support. In exams, you may be asked to explain why Unicode is preferred for global applications or to decode given binary patterns according to ASCII/Unicode.

Unicode 的开发旨在支持全世界所有书写系统的字符。它最多可以使用 32 位来表示一个字符,不过像 UTF-8 这样的常见编码使用可变字节数,以在编码海量字符的同时保持与 ASCII 的兼容性。Unicode 相对于 ASCII 的主要优势是其全面的多语言支持。在考试中,你可能会被要求解释为什么全球应用中优先选择 Unicode,或者根据 ASCII/Unicode 解码给定的二进制模式。


10. Error Detection: Parity Bits and Checksums | 错误检测:奇偶校验与校验和

When data is transmitted or stored, errors can occur due to noise or hardware faults. Parity bits are a simple error-detection method. A parity bit is added to a binary string to make the total number of 1-bits either even (even parity) or odd (odd parity). The receiver calculates the parity of the received data; if it does not match the expected parity, an error is detected, though it cannot correct the error nor detect an even number of bit flips.

当数据被传输或存储时,可能因噪声或硬件故障而产生错误。奇偶校验位是一种简单的错误检测方法。在二进制串中附加一个奇偶校验位,使得整个数据中 1 的总数为偶数(偶校验)或奇数(奇校验)。接收方计算收到数据的奇偶性,若与预期不符,则检测到错误,但它无法纠正错误,也无法检测偶数个位翻转的情况。

A checksum is another detection technique where the sender computes a numerical value based on the data (e.g., sum of bytes modulo 256) and appends it. The receiver performs the same calculation and compares the results. More sophisticated methods like cyclic redundancy checks (CRC) are used in network protocols. Edexcel focuses on understanding parity bits and checksums, including their limitations, such as inability to correct errors or detect certain multiple-bit errors.

校验和是另一种错误检测技术,发送方基于数据计算出一个数值(例如,所有字节的和模 256),并将其附加在数据后。接收方执行相同的计算并比较结果。网络协议中还使用更复杂的方法,如循环冗余校验 (CRC)。Edexcel 重点考查对奇偶校验位和校验和的理解,包括它们的局限性,例如无法纠正错误或检测特定的多比特错误。

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

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