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

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

Binary is the fundamental number system that underpins all modern computers. In the AQA A-Level Computer Science specification, a solid grasp of binary representation, arithmetic, and related concepts is essential for understanding how data is stored, processed, and transmitted. This revision guide unpacks every critical binary topic – from basic conversions to floating‑point normalisation – with clear explanations, worked examples, and bilingual notes to support your learning.

二进制是所有现代计算机的基础数制。在AQA A-Level计算机科学大纲中,扎实掌握二进制表示、运算及相关概念是理解数据如何存储、处理和传输的关键。这本考点精讲将逐一剖析每一个重要二进制专题——从基本转换到浮点归一化——通过清晰的解释、典型示例和双语注释,帮助你巩固知识。


1. The Binary Number System | 二进制数制

Computers use binary because they rely on two‑state electronic circuits (on/off, high/low voltage). A binary digit, or bit, can be either 0 or 1. A group of 8 bits is called a byte, and larger units such as kibibyte (KiB), mebibyte (MiB) are also defined. In binary notation, we often write the subscript 2, for example 1101₂. The rightmost bit is the least significant bit (LSB) and the leftmost is the most significant bit (MSB). Each position represents a power of 2: 2ⁿ, where n starts from 0 at the LSB.

计算机使用二进制,因为它依赖双态电子电路(开/关、高/低电压)。一个二进制数字,即位(bit),只能是0或1。8位称为一个字节(byte),更大的单位如kibibyte (KiB)、mebibyte (MiB)也被定义。书写时通常加下标2,如1101₂。最右边的位是最低有效位(LSB),最左边的是最高有效位(MSB)。每一位都代表2的幂:2ⁿ,n在LSB处从0开始。

2. Binary to Decimal Conversion | 二进制与十进制互换

To convert a binary integer to decimal, multiply each bit by its place value (2ⁿ) and sum the results. For example, 1011₂ = 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 8 + 0 + 2 + 1 = 11₁₀.

要将二进制整数转换为十进制,只需将每位乘以其位权(2ⁿ)并求和。例如,1011₂ = 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 8 + 0 + 2 + 1 = 11₁₀。

To convert a decimal integer to binary, repeatedly divide by 2 and record the remainders. The binary number is the sequence of remainders read from the last division upwards. For 25₁₀: 25 ÷ 2 = 12 remainder 1; 12 ÷ 2 = 6 remainder 0; 6 ÷ 2 = 3 remainder 0; 3 ÷ 2 = 1 remainder 1; 1 ÷ 2 = 0 remainder 1. Reading remainders upwards gives 11001₂.

将十进制整数转换为二进制,反复除以2并记录余数,从下往上读取余数即得二进制数。以25₁₀为例:25 ÷ 2 = 12 余 1; 12 ÷ 2 = 6 余 0; 6 ÷ 2 = 3 余 0; 3 ÷ 2 = 1 余 1; 1 ÷ 2 = 0 余 1。向上读取余数得11001₂。

3. Hexadecimal Representation | 十六进制表示

Hexadecimal (base‑16) is widely used in computing because it compactly represents binary strings. Each hex digit corresponds to exactly 4 bits (a nibble). Digits 0‑9 are used, and letters A‑F represent 10‑15. For instance, 1011 1100₂ can be split into nibbles: 1011₂ = B₁₆, 1100₂ = C₁₆, giving BC₁₆. Conversion to decimal from hex uses powers of 16: BC₁₆ = 11×16¹ + 12×16⁰ = 176 + 12 = 188₁₀. AQA expects fluency in converting between denary, binary and hexadecimal.

十六进制(基数为16)在计算中广泛使用,因为它能紧凑地表示二进制串。每位十六进制数字恰好对应4位(一个半字节)。数字0‑9沿用,字母A‑F代表10‑15。例如,1011 1100₂可按半字节拆分:1011₂ = B₁₆,1100₂ = C₁₆,得BC₁₆。将十六进制转十进制使用16的幂:BC₁₆ = 11×16¹ + 12×16⁰ = 176 + 12 = 188₁₀。AQA要求熟练地在十进制、二进制和十六进制之间转换。

4. Binary Addition | 二进制加法

Binary addition follows these rules: 0+0=0, 0+1=1, 1+0=1, 1+1=0 carry 1, and 1+1+1=1 carry 1. When adding two bytes, a carry out from the MSB could generate an overflow (see section 10). For example: 1011₂ (11) + 0110₂ (6) = 10001₂ (17). In an 8‑bit register, this result would require 5 bits; if stored in 4 bits, the carry is lost, causing an overflow error.

二进制加法遵循以下规则:0+0=0, 0+1=1, 1+0=1, 1+1=0 进位1,以及1+1+1=1 进位1。当两个字节相加时,MSB产生的进位可能引起溢出(见第10节)。例如:1011₂ (11) + 0110₂ (6) = 10001₂ (17)。在8位寄存器中,这个结果需要5位;若仅用4位存储,进位将丢失,导致溢出错误。

5. Signed Binary – Sign & Magnitude | 带符号二进制 – 原码

To represent negative numbers, we need signed representations. The simplest is sign and magnitude. The MSB acts as the sign bit: 0 for positive, 1 for negative; the remaining bits store the magnitude. In an 8‑bit system, +5 is 00000101₂ and −5 is 10000101₂. This method has two representations for zero (00000000 and 10000000), complicates arithmetic, and is rarely used in ALUs.

为了表示负数,需要使用有符号表示。最简单的是原码(sign and magnitude)。MSB作为符号位:0表示正数,1表示负数;其余位存放数值大小。在8位系统中,+5表示为00000101₂,−5为10000101₂。该方法存在两个零(00000000和10000000),算术运算复杂,在现代算术逻辑单元中很少使用。

6. Two’s Complement | 补码(二进制补码)

Two’s complement is the standard method for signed integers in modern computers. To obtain the two’s complement representation of a negative number:

  • Write the positive binary value (include leading zeros to fill the required width).
  • Invert all bits (one’s complement).
  • Add 1 to the result.

For example, −13 in 8 bits: 13 = 00001101₂ → invert → 11110010₂ → add 1 → 11110011₂. The MSB is still a sign indicator (0 positive, 1 negative). Two’s complement has only one zero (00000000), and subtraction can be performed by adding the two’s complement of the subtrahend.

补码是现代计算机中表示有符号整数的标准方法。获得一个负数的补码表示的步骤:

  • 写出其正数的二进制值(补上前导零到所需位数)。
  • 将所有位取反(反码)。
  • 在结果上加1。

例如,−13用8位补码表示:13 = 00001101₂ → 取反 → 11110010₂ → 加1 → 11110011₂。MSB仍为符号标志(0正1负)。补码只有一个零(00000000),减法可通过加上减数的补码来实现。

7. Fixed‑Point Binary | 定点二进制

Fixed‑point representation allows fractional numbers by placing a binary point at a fixed position. In an 8‑bit fixed‑point format with 4 bits for the integer part and 4 bits for the fractional part, the place values are 2³ 2² 2¹ 2⁰ . 2⁻¹ 2⁻² 2⁻³ 2⁻⁴. For example, 0110.1001₂ = 0×8 + 1×4 + 1×2 + 0×1 + 1×0.5 + 0×0.25 + 0×0.125 + 1×0.0625 = 6.5625₁₀. Negative fixed‑point numbers are stored in two’s complement, where the binary point still separates integer and fractional parts.

定点表示通过将二进制小数点固定在某个位置来表示小数。在一个8位定点格式中,若整数部分4位,小数部分4位,则位权为2³ 2² 2¹ 2⁰ . 2⁻¹ 2⁻² 2⁻³ 2⁻⁴。例如,0110.1001₂ = 0×8 + 1×4 + 1×2 + 0×1 + 1×0.5 + 0×0.25 + 0×0.125 + 1×0.0625 = 6.5625₁₀。负定点数采用补码存储,二进制小数点同样分隔整数和小数部分。

8. Floating‑Point Binary (Normalisation) | 浮点二进制(归一化)

Floating‑point representation uses a mantissa and an exponent to represent a vastly wider range of values. In AQA, a common format allocates, say, 8 bits for the mantissa and 4 bits for the exponent (both in two’s complement). The decimal number is given by mantissa × 2exponent. To maximise precision, numbers are normalised: the mantissa is adjusted so that its first two bits are different (01… or 10…), which means the MSB of the mantissa is the opposite of the bit immediately after it. For a positive mantissa, normalised form starts with 01; for negative, with 10. Normalisation removes leading zeros or redundant ones.

浮点表示使用尾数(mantissa)指数(exponent)来表示数值范围极广的数。在AQA中,常见格式例如尾数8位、指数4位(均用补码)。十进制数值 = 尾数 × 2指数。为最大化精度,数值需归一化(normalised):调整尾数使前两位不同(01…或10…),即尾数的MSB必须与其紧邻位相反。正尾数的归一化形式以01开头;负尾数以10开头。归一化去除了前导零或冗余的1。

Example: Represent 3.5₁₀ in an 8‑bit mantissa, 4‑bit exponent format. First, 3.5 = 11.1₂ = 0.111₂ × 2². The mantissa (two’s complement) must be 01110000 (pad to 8 bits, positive). The exponent (two’s complement, 4 bits) for +2 is 0010. The normalised floating‑point representation is 01110000 0010.

示例:用8位尾数、4位指数格式表示3.5₁₀。首先,3.5 = 11.1₂ = 0.111₂ × 2²。尾数(补码)应为01110000(填充至8位,正数)。指数(4位补码)+2为0010。归一化浮点表示为 01110000 0010。

9. Logical Shifts and Arithmetic Shifts | 逻辑移位与算术移位

Shifts are bitwise operations used for multiplication or division by powers of two, and for manipulating data. A logical shift moves all bits left or right, filling vacated positions with 0. A left logical shift by 1 multiplies an unsigned integer by 2; a right logical shift by 1 divides by 2 (ignoring remainder). Arithmetic shifts preserve the sign bit: in an arithmetic right shift, the MSB (sign) is replicated into the vacated positions, which correctly divides a two’s complement number by 2, rounding towards negative infinity. An arithmetic left shift is identical to a logical left shift, but overflow must be checked carefully as shifting can change the sign.

移位是按位操作,用于乘以或除以2的幂次,以及数据处理。逻辑移位将所有位左移或右移,空出位填0。左逻辑移1位将无符号整数乘以2;右逻辑移1位则除以2(忽略余数)。算术移位保留符号位:在算术右移中,MSB(符号位)被复制到空出的位置,这能正确地将补码数除以2,并向负无穷方向舍入。算术左移与逻辑左移相同,但必须仔细检查溢出,因为移位可能改变符号。

10. Overflow and Underflow | 溢出与下溢

Overflow occurs when the result of an arithmetic operation exceeds the representable range for a given number of bits. In two’s complement addition, overflow is detected when the carry into the sign bit differs from the carry out of the sign bit. For example, adding two large positive numbers may produce a result that appears negative if overflow goes undetected. Underflow refers to floating‑point numbers where the result is so close to zero that it cannot be represented in the normalised format; the smallest normalised non‑zero value is bounded by the minimum exponent.

溢出发生在算术运算的结果超出给定位数所能表示的范围时。在补码加法中,当进入符号位的进位与出符号位的进位不同时,即检测到溢出。例如,两个大的正数相加可能产生看似负数的结果,若未检测溢出则导致错误。下溢指浮点数的结果太过接近零,以至于无法用归一化格式表示;最小的归一化非零值受限于最小指数。

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