IB Edexcel Computer Science: Binary Exam Essentials | IB Edexcel 计算机:二进制 考点精讲

📚 IB Edexcel Computer Science: Binary Exam Essentials | IB Edexcel 计算机:二进制 考点精讲

Binary is the backbone of all modern computing systems. From storing numbers and characters to representing images and sound, everything inside a computer ultimately boils down to sequences of 0s and 1s. This article consolidates every key topic you need to master for the IB and Edexcel Computer Science examinations: number conversion, binary arithmetic, two’s complement representation, text and multimedia encoding, logical shifts, and bitwise operations. Each section is structured as a crisp explanation followed by its Chinese counterpart for bilingual clarity.

二进制是所有现代计算系统的基石。无论是数字、字符的存储,还是图像和声音的表示,计算机内部的一切最终都归结为0和1的序列。本文浓缩了IB和Edexcel计算机科学考试中必须掌握的所有核心知识点:进制转换、二进制算术、补码表示、文本与多媒体编码、逻辑移位以及位运算。每一小节都以简明的英文讲解配以对应的中文阐释,方便双语学习。

1. Introduction to the Binary Number System | 二进制数制简介

A binary digit, or bit, can hold exactly one of two values: 0 or 1. Computers use binary because transistors — the fundamental building blocks of a processor — have two stable states, typically representing ‘off’ (0) and ‘on’ (1). All data, whether a number, a letter, or a colour, is encoded as a pattern of bits. The weight of each bit position is a power of 2, starting from 2⁰ on the rightmost bit.

一个二进制位(bit)只能取两个值之一:0或1。计算机使用二进制,是因为处理器的基础元件晶体管具有两种稳定状态,通常代表”关”(0)和”开”(1)。所有数据,无论是数字、字母还是颜色,都被编码为位模式的组合。每一位的权重是2的幂,从最右侧的2⁰开始。

2. Converting Between Binary and Denary | 二进制与十进制转换

To convert a binary number to denary (decimal), line up the powers of 2 above each bit, starting from the rightmost bit as 2⁰. For example, the binary number 1011₂ equals (1×8)+(0×4)+(1×2)+(1×1) = 11₁₀. To convert denary to binary, repeatedly divide the number by 2 and record the remainders; read the remainders backwards to form the binary equivalent. For 13₁₀: 13÷2 = 6 r1, 6÷2 = 3 r0, 3÷2 = 1 r1, 1÷2 = 0 r1 → binary 1101₂.

将二进制转换为十进制时,需要在每一位上方标出2的幂,最右侧位为2⁰。例如二进制数1011₂等于(1×8)+(0×4)+(1×2)+(1×1)=11₁₀。将十进制转换为二进制时,不断用2除该数并记录余数,最后将余数反向排列即得二进制结果。以13₁₀为例:13÷2=6余1,6÷2=3余0,3÷2=1余1,1÷2=0余1 → 二进制1101₂。

3. Binary Addition and Overflow | 二进制加法与溢出

Binary addition follows four simple rules: 0+0=0, 0+1=1, 1+0=1, 1+1=0 with a carry of 1. When adding two 8-bit numbers, if the result requires 9 bits, an overflow occurs. Overflow happens when a value is too large to fit into the allocated number of bits. In a processor, an overflow flag is typically set to indicate that the result is incorrect if interpreted as an unsigned number within the fixed bit-width.

二进制加法遵循四条简单规则:0+0=0,0+1=1,1+0=1,1+1=0并向高位进1。当对两个8位数进行加法时,如果结果需要9位,则会产生溢出。溢出发生在数值过大而无法放入指定位数时。处理器中通常会设置溢出标志,以指示在固定位宽下解释为无符号数时结果不正确。

4. Representing Negative Numbers: Two’s Complement | 负数表示:二进制补码

Two’s complement is the most common method for representing signed integers in binary. To obtain the two’s complement of a positive binary number, invert all bits (one’s complement) and add 1 to the least significant bit. For an 8-bit system, the range of representable values is from –128 to 127. The most significant bit (MSB) acts as the sign bit: 0 for positive and zero, 1 for negative. For example, –5 in 8-bit two’s complement: write +5 as 00000101, invert to 11111010, add 1 → 11111011.

二进制补码是表示有符号整数最常用的方法。求一个正二进制数的补码时,先对所有位取反(反码),然后加1。在8位系统中,可表示的数值范围是-128到127。最高位(MSB)用作符号位:0表示正数和零,1表示负数。例如,8位补码表示-5:先写出+5为00000101,取反得11111010,加1 → 11111011。

5. Binary Subtraction Using Two’s Complement | 使用补码进行二进制减法

Instead of building separate subtraction circuits, processors perform subtraction by adding the two’s complement of the subtrahend. To calculate A – B, compute A + (two’s complement of B) and ignore any carry out of the MSB if the numbers are within the representable range. For example, 7 – 3 in 4-bit two’s complement: 7 is 0111, 3 is 0011, two’s complement of 3 is 1101. 0111 + 1101 = 10100, discard the 5th bit → 0100, which is 4.

处理器并不设立独立的减法电路,而是通过加上减数的补码来实现减法。计算A – B时,只需计算A + (B的补码),如果数值在可表示范围内,则忽略超出MSB的进位。例如,4位补码计算7 – 3:7为0111,3为0011,3的补码为1101。0111+1101=10100,舍弃第5位 → 0100,即为4。

6. Binary Multiplication and Division (Logical Shifts) | 二进制乘除与逻辑移位

Shifting a binary number left by one position multiplies it by 2; shifting right by one position divides it by 2 (integer division, discarding remainder). A logical left shift moves all bits one place to the left, fills the LSB with 0, and the MSB is lost. A logical right shift moves bits right, fills the MSB with 0, and the LSB is discarded. Repeated shifts allow multiplication or division by powers of 2. Be aware that right-shifting a negative two’s complement number using a logical shift destroys the sign, so arithmetic shifts are used instead for signed division.

将二进制数左移一位相当于乘以2,右移一位相当于除以2(整除,舍弃余数)。逻辑左移将所有位向左移动一位,最低位补0,最高位丢失。逻辑右移则将位右移,最高位补0,最低位丢弃。多次移位可实现乘或除以2的幂。需要注意的是,对补码表示的负数进行逻辑右移会破坏符号位,因此在有符号除法中应改用算术移位。

7. Text Encoding: ASCII and Unicode | 文本编码:ASCII 与 Unicode

Characters are stored in binary using agreed-upon encoding schemes. ASCII uses 7 bits (often stored as 8 bits with a leading zero) to represent 128 characters, including English letters, digits, punctuation, and control codes. Unicode extends this to represent characters from virtually all world scripts. The most common Unicode encoding, UTF-8, uses 1 to 4 bytes per character and is backward compatible with ASCII. Knowing how character sets correspond to binary codes is a frequent exam requirement.

字符通过约定的编码方案以二进制形式存储。ASCII使用7位(通常以8位存储,前导零)表示128个字符,包括英文字母、数字、标点符号和控制码。Unicode将其扩展,几乎涵盖世界上所有书写系统的字符。最常用的Unicode编码UTF-8为每个字符使用1到4个字节,并与ASCII向后兼容。理解字符集与二进制码的对应关系是考试中的常见要求。

8. Representing Images: Pixels and Colour Depth | 图像表示:像素与颜色深度

A bitmap image is a grid of pixels. Each pixel’s colour is stored as a binary value. The colour depth, measured in bits per pixel (bpp), determines how many distinct colours can be represented. For example, 1 bpp gives 2 colours (black and white), 8 bpp gives 256 colours, and 24 bpp (true colour) uses 8 bits each for red, green, and blue, producing over 16 million colours. Image file size can be estimated as: width × height × colour depth (in bits). Metadata and compression also affect final file size.

位图图像是一个像素网格。每个像素的颜色以二进制值存储。颜色深度以每像素位数(bpp)衡量,决定了可以表示的不同颜色数量。例如,1 bpp可表示2种颜色(黑白),8 bpp可得256色,而24 bpp(真彩色)为红绿蓝各分配8位,可产生超过1600万种颜色。图像文件大小可估算为:宽度×高度×颜色深度(以位计)。元数据和压缩也会影响最终文件大小。

9. Representing Sound: Sampling and Bit Depth | 声音表示:采样与位深度

Sound is analogue by nature and must be converted to digital form via sampling. An analogue-to-digital converter (ADC) measures the amplitude of the sound wave at regular intervals (sample rate) and records each sample as a binary number of a certain bit depth. Higher sample rates capture higher frequencies; greater bit depth yields finer amplitude resolution. The bit rate is sample rate × bit depth × number of channels. Standard CD quality uses 44.1 kHz sample rate and 16-bit depth, resulting in 1411 kbps for stereo audio.

声音本质上是模拟信号,必须通过采样转换为数字形式。模数转换器(ADC)以固定频率(采样率)测量声波振幅,并将每个样本记录为特定位深的二进制数。更高的采样率可以捕捉更高的频率;更大的位深能提供更细腻的幅度分辨率。比特率 = 采样率 × 位深度 × 声道数。标准CD音质采用44.1 kHz采样率和16位深度,立体声音频的比特率为1411 kbps。

10. Bitwise Operations (AND, OR, XOR, NOT) | 位运算(与、或、异或、非)

Bitwise operators act on individual bits of binary numbers. AND returns 1 only if both corresponding bits are 1. OR returns 1 if at least one bit is 1. XOR (exclusive OR) returns 1 if bits are different. NOT inverts all bits. These operations are heavily used in low-level programming for masking, setting/clearing specific bits, and performing efficient arithmetic. Truth tables are essential for understanding and predicting the outcome of bitwise logic.

位运算对二进制数的每个位独立操作。AND仅在两个对应位均为1时返回1。OR在至少一位为1时返回1。XOR(异或)在位不同时返回1。NOT将所有位取反。这些运算广泛用于底层编程的掩码操作、设置/清零特定位以及快速算术。真值表对理解和预测位逻辑的结果至关重要。

11. Memory and Data Size Units | 存储与数据大小单位

Digital data is measured in units based on powers of 2. A nibble is 4 bits, a byte is 8 bits. A kilobyte (KB) traditionally equals 1024 bytes (2¹⁰), though some contexts use 1000 bytes. Megabyte (MB), gigabyte (GB), terabyte (TB), and petabyte (PB) progressively multiply by 1024. In networking and storage marketing, decimal prefixes (1000) are often used. Understanding these units and the relationship between bit and byte is crucial for data transfer and storage calculations.

数字数据以基于2的幂的单位来衡量。一个”半字节”(nibble)是4位,一个字节是8位。传统上1千字节(KB)等于1024字节(2¹⁰),尽管某些语境下用1000字节。兆字节(MB)、吉字节(GB)、太字节(TB)和拍字节(PB)依次乘以1024。在网络和存储产品营销中,常使用十进制前缀(1000)。理解这些单位以及位与字节之间的关系,对数据传输和存储计算至关重要。


12. Exam Tips and Common Mistakes | 考试技巧与常见错误

Always show your working when converting between bases. Double-check two’s complement range: for n bits, range is –2ⁿ⁻¹ to 2ⁿ⁻¹–1. When performing binary addition, clearly indicate carries. Be careful not to confuse logical and arithmetic shifts; arithmetic right shift preserves the sign bit for two’s complement numbers. In encoding questions, ensure you know the exact number of bits per character for ASCII (7 or 8) or Unicode (variable). Finally, when calculating file sizes, keep all units consistent and watch out for bits versus bytes.

在进行进制转换时务必展示步骤。仔细检查补码范围:对于n位,范围是–2ⁿ⁻¹到2ⁿ⁻¹–1。做二进制加法时要明确标出进位。注意不要混淆逻辑移位和算术移位;针对补码数的算术右移会保留符号位。在编码类题目中,确保清楚ASCII(7或8位)和Unicode(可变长度)的每位字符位数。最后,计算文件大小时,保持单位一致并注意区分比特与字节。

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