📚 GCSE WJEC Computer Science: Binary in Depth | WJEC GCSE 计算机:二进制考点精讲
Binary is the fundamental language of all modern computers. Every piece of data, every instruction, and every pixel on your screen is ultimately represented using only two digits: 0 and 1. This article breaks down the essential binary concepts you need to master for your WJEC GCSE Computer Science exam, from number conversions to addition, shifts, and negative number representation.
二进制是所有现代计算机的基本语言。每一条数据、每一条指令以及屏幕上的每一个像素,最终都只用两个数字表示:0 和 1。本文将分解你在 WJEC GCSE 计算机科学考试中需要掌握的核心二进制概念,从数制转换到加法、移位,再到负数表示。
1. Understanding the Binary System | 理解二进制系统
Computers use the binary number system (base-2) because transistors, which are the building blocks of digital circuits, can reliably represent two states: on (1) and off (0). This binary code allows complex data to be stored and processed with extreme speed and reliability.
计算机使用二进制数制(基数为2),因为作为数字电路基本构件的晶体管能够可靠地表示两种状态:开(1)和关(0)。这种二进制代码使复杂的数据能够以极高的速度和可靠性进行存储和处理。
In binary, each column heading (place value) is a power of 2. Starting from the rightmost bit, the place values are 2⁰ (1), 2¹ (2), 2² (4), 2³ (8), and so on. An 8‑bit binary number has place values from 2⁰ to 2⁷, giving a maximum denary value of 255.
在二进制中,每个列的标题(位权)都是 2 的幂。从最右边的位开始,位值依次为 2⁰(1)、2¹(2)、2²(4)、2³(8)等等。一个 8 位二进制数的位值范围从 2⁰ 到 2⁷,可表示的最大十进制值为 255。
| Power of 2 (2的幂) | 2⁷ | 2⁶ | 2⁵ | 2⁴ | 2³ | 2² | 2¹ | 2⁰ |
| Denary value (十进制值) | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Each 0 or 1 is called a bit (binary digit). Groups of 8 bits form a byte, which is the standard unit of memory. Larger groupings like kilobytes (kB), megabytes (MB) and gigabytes (GB) are all multiples of bytes.
每个 0 或 1 被称为一个比特(二进制位)。8 个比特组成一个字节,这是内存的标准单位。更大的单位如千字节 (kB)、兆字节 (MB) 和吉字节 (GB) 都是字节的倍数。
2. Binary to Denary Conversion | 二进制转十进制
To convert a binary number to denary, write the binary digits under the place value headings and add up the values where a 1 appears. For example, the binary number 11001010 is placed as follows:
要将二进制数转换为十进制,把二进制数字写在位权标题下方,然后将出现 1 的位置的值相加。例如,二进制数 11001010 的放置方式如下:
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| 1 | 1 | 0 | 0 | 1 | 0 | 1 | 0 |
So 11001010 in binary is 202 in denary. This method works for any length of binary number.
将标有 1 的位值相加:128 + 64 + 8 + 2 = 202。因此二进制 11001010 对应十进制 202。此方法适用于任何长度的二进制数。
Always double-check your arithmetic and make sure you align the bits correctly from the right. A common mistake is to reverse the place value order.
一定要仔细核对算术,并确保从右端正确对齐各数位。常见的错误是将位权顺序颠倒。
3. Denary to Binary Conversion | 十进制转二进制
The most reliable method for converting a denary number to binary is the division by 2 method. You repeatedly divide the denary number by 2, writing down the remainder (0 or 1) each time, until the quotient becomes 0. Read the remainders from bottom to top to obtain the binary equivalent.
将十进制数转换为二进制最可靠的方法是除以 2 取余法。反复将十进制数除以 2,每次记下余数(0 或 1),直到商变为 0。从下往上读取余数即可得到对应的二进制数。
Take 202 as an example:
以 202 为例:
- 202 ÷ 2 = 101 remainder 0 (LSB)
- 101 ÷ 2 = 50 remainder 1
- 50 ÷ 2 = 25 remainder 0
- 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 (MSB)
Reading from bottom to top: 11001010. This matches our earlier conversion. For exam questions, you may be asked to represent the answer in an 8‑bit format, so add leading zeros to make up 8 bits if necessary.
从下往上读取:11001010。这与我们之前的转换结果一致。在考试题目中,你可能需要用 8 位格式表示答案,因此必要时要在前面补零凑足 8 位。
4. Binary and Hexadecimal | 二进制与十六进制
for humans to read. Each hex digit represents exactly 4 bits (a nibble). The digits are 0–9 and A–F, where A = 10, B = 11, …, F = 15.
十六进制(基数为16)常被用作二进制的简写形式,因为它更紧凑,更易于人类阅读。每个十六进制位恰好代表 4 个比特(一个半字节)。数字为 0–9 和 A–F,其中 A = 10,B = 11,……,F = 15。
or 11001010, the groups are 1100 and 1010: 1100 = C (12), 1010 = A (10), giving CA in hex.
将二进制转换为十六进制时,从右端开始将二进制数每 4 位分为一组,然后将每组转换。对于 11001010,分组为 1100 和 1010:1100 = C (12),1010 = A (10),因此十六进制为 CA。
Hexadecimal is not just a conversion exercise; it is widely used in memory addressing, colour codes (e.g., #FF0088), and low‑level programming. Being fluent in binary‑hex conversion saves time and reduces errors.
十六进制不只是一项转换练习;它还广泛用于内存寻址、颜色值(例如 #FF0088)以及底层编程中。熟练掌握二进制与十六进制的互换可以节省时间,减少错误。
5. Binary Addition | 二进制加法
using simple rules: 0+0=0, 1+0=1, 0+1=1, and 1+1=0 carry 1, 1+1+1=1 carry 1. Adding two 8‑bit numbers works column by column from the right, just like denary addition.
计算机的算术逻辑单元 (ALU) 使用简单的规则执行二进制加法:0+0=0、1+0=1、0+1=1、1+1=0 进位1、1+1+1=1 进位1。两个 8 位二进制数的加法与十进制加法一样,从右端逐列进行。
Example: 01011100 (92) + 00110101 (53)
示例:01011100 (92) + 00110101 (53)
01011100
+ 00110101
――――――
10010001
result is 10010001, which equals 145 in denary, as expected. Always check the final carry‑out: if it exceeds 8 bits, an overflow occurs.
从最右边的位开始相加:0+1=1;0+0=0;1+1=0 进位1;然后 1(进位)+1+0=0 再进位1;依此类推。结果为 10010001,对应十进制 145,与预期一致。务必检查最终的进位输出:如果超过 8 位,则会发生溢出。
6. Overflow Errors | 溢出错误
Overflow occurs when the result of a binary addition requires more bits than the available storage. For example, adding two 8‑bit numbers can produce a 9‑bit result, which cannot fit in an 8‑bit register. The extra bit is lost, producing an incorrect answer.
当二进制加法的结果所需的位数超过可用存储位数时,就会发生溢出。例如,两个 8 位数相加可能产生一个 9 位的结果,这在一个 8 位寄存器中是存不下的。多余的位会丢失,导致答案出错。
Consider 11111111 (255) + 00000001 (1). The sum is 1 00000000, which is the 9‑bit value 256. In an 8‑bit system, the ninth bit is discarded, leaving 00000000. This clearly is not the correct sum, illustrating how overflow can cause critical software bugs.
考虑 11111111 (255) + 00000001 (1)。其和为 1 00000000,即 9 位值 256。在 8 位系统中,第 9 位被丢弃,剩下 00000000。这显然不是正确的总和,说明了溢出会如何导致严重的软件错误。
In your WJEC exam, you may be asked to identify if an overflow has occurred by checking whether there is a carry into the ninth bit. You should also be aware that the processor uses a flag register to record such events.
在 WJEC 考试中,你可能需要通过检查是否有进位进入第 9 位来判断是否发生了溢出。你还应了解,处理器会使用标志寄存器来记录此类事件。
7. Logical Binary Shifts | 逻辑移位
A logical shift moves every bit in a binary number a certain number of places to the left or right, filling the vacated positions with 0s. Left shifting multiplies the number by 2 for each shift; right shifting divides by 2 (integer division, discarding any remainder).
逻辑移位将二进制数中的每个位向左或向右移动一定的位数,空出的位置用 0 填充。每左移一位相当于将原数乘以 2;每右移一位相当于除以 2(整数除法,舍弃余数)。
Take 00101000 (40 in denary):
以 00101000(十进制 40)为例:
- Left shift by 1: 01010000 (= 80)
- Left shift by 2: 10100000 (= 160)
- Right shift by 1: 00010100 (= 20)
- Right shift by 2: 00001010 (= 10)
Notice that shifting can cause bits to 'fall off' the end and be lost. For instance, left shifting 10101010 by 1 gives 01010100, but the original MSB (1) is lost. You must be able to perform and analyse such shifts in exam questions.
注意,移位可能导致一些位从末端“掉落”并丢失。例如,将 10101010 左移 1 位得到 01010100,但原来的最高有效位 (1) 丢失了。你必须在考试题目中能够执行并分析这样的移位操作。
8. Representing Negative Numbers | 负数的表示
Since binary systems cannot store a minus sign directly, two common methods are used to represent negative integers: sign‑and‑magnitude and two’s complement. In sign‑and‑magnitude, the most significant bit (MSB) is the sign bit: 0 for positive, 1 for negative, and the remaining bits hold the magnitude.
由于二进制系统无法直接存储负号,通常使用两种方法来表示负整数:原码表示法(符号‑数值)和补码表示法(二进制补码)。在原码中,最高有效位 (MSB) 是符号位:0 表示正,1 表示负,其余位存放数值。
For example, +5 in 4‑bit sign‑and‑magnitude is 0101; −5 is 1101. However, this representation has problems, such as two zeros (+0: 0000, –0: 1000) and complicated arithmetic. Therefore, modern computers use two’s complement.
例如,4 位原码中 +5 是 0101;−5 是 1101。然而,这种表示法存在缺陷,比如有两个零(+0:0000,–0:1000)以及运算复杂。因此,现代计算机采用二进制补码。
To find the two’s complement of a negative number:
- Write the positive binary equivalent.
- Invert all bits (flip 0→1, 1→0).
- Add 1 to the inverted result.
示例:求 −5 的 4 位补码。+5 = 0101。按位取反得 1010。加 1 得 1011。因此 −5 的补码表示为 1011。
求负数的二进制补码:
- 写出其绝对值的二进制形式。
- 将所有位取反(0→1,1→0)。
- 在取反结果上加 1。
Example: to represent −5 in 4‑bit two' . Add 1: 1011. So −5 is 1011. Two’s complement makes addition straightforward, and there is only one representation for zero. The exam expects you to convert both ways and identify the range of an n‑bit two’s complement number (−2ⁿ⁻¹ to 2ⁿ⁻¹−1).
补码使加法非常简单,并且零只有一种表示方式。考试要求你能进行双向转换,并能确定 n 位补码数的表示范围(−2ⁿ⁻¹ 到 2ⁿ⁻¹−1)。
9. Binary in the Wider World | 二进制在更广领域中的应用
Everything inside a computer is ultimately binary. Text is encoded using character sets such as ASCII and Unicode, where each character is assigned a unique binary pattern. For example, standard ASCII represents 'A' as 01000001 (65). Images are stored as binary records of pixel colours, and sound is stored as binary samples.
计算机内的一切归根结底都是二进制。文本使用 ASCII 和 Unicode 等字符集进行编码,其中每个字符都被赋予一个唯一的二进制模式。例如,标准 ASCII 用 01000001 (65) 表示 'A'。图像以像素颜色的二进制记录来存储,声音则以二进制采样形式存储。
Understanding binary representation helps you grasp why file sizes grow with higher resolution, colour depth, or sample rates. It also underpins all the logic circuits and micro‑instructions inside the processor. This deep awareness will make the more advanced topics in GCSE Computer Science much clearer.
理解二进制表示有助于你明白为什么文件大小会随着分辨率、颜色深度或采样率的提高而增长。它也是处理器内部所有逻辑电路和微指令的基础。这种深刻的认识将使你更清晰地理解 GCSE 计算机科学中更高级的主题。
Published by TutorHao | Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)

或截图后用「扫一扫 → 相册」选择本图