First exams 2027 · SL & HL 2027 年首次开考 · SL 与 HL

A1.2.1 · Computer fundamentals

A1.2.1 · 计算机基础

Principal Methods of Representing Data

表示数据的主要方法

Everything inside a computer is a string of two symbols, 0 and 1. To work with those strings, people need agreed ways to write them down and to move between them and ordinary decimal. Binary and hexadecimal are those two systems.

计算机内部的一切都是由两个符号 0 和 1 组成的串。要处理这些串,人们需要约定好的方式来书写它们,以及在它们和普通十进制之间转换。二进制和十六进制就是这两套系统。

A1's guiding question asks what principles underpin how a computer works. The first: two states are enough to represent any number, and a base is just a choice of how many symbols each digit position uses.

A1 的引导性问题问的是支撑计算机运行的原理。第一个原理:两种状态就足以表示任何数,而"进制"只是选择每个数位使用多少个符号。

Core for SL & HL SL 与 HL 核心内容 Typically 1–4 marks · AO2 通常 1–4 分 · AO2 Command term: describe 命令词:describe(描述)

Explainer

讲解

Why binary, and why hexadecimal on top

为什么用二进制,又为什么再加上十六进制

Df

Binary (base-2) uses two symbols, 0 and 1. Each digit is a bit, and eight bits make a byte. Hardware likes it because a switch (a transistor) is either off (0) or on (1), and two clearly separated states survive electrical noise far better than ten would.

二进制(基数 2)使用两个符号 0 和 1。每一位叫做一个位(bit),八个位组成一个字节(byte)。硬件喜欢它,因为一个开关(晶体管)要么关(0)要么开(1),而两种清晰分开的状态比十种更能经受电噪声的干扰。

Df

Hexadecimal (base-16), often shortened to hex, uses sixteen symbols: 0 to 9, then A, B, C, D, E, F for the values 10 to 15. It is not how the computer stores anything. It is a shorthand for people, because one hex digit stands for exactly four bits (a nibble), so a long binary string becomes a quarter as many characters to read and write.

十六进制(基数 16),常简称 hex,使用十六个符号:0 到 9,然后用 A、B、C、D、E、F 表示 10 到 15。它并不是计算机存储数据的方式,而是给人用的速记,因为一个十六进制数字正好代表四个位(一个半字节 nibble),所以一长串二进制就变成了四分之一那么多的字符,更好读也更好写。

Three conversions this statement expects 本条考纲要求掌握的三种转换

Binary to decimal and back, hexadecimal to decimal and back, and binary to hexadecimal and back. The binary-to-hex pair is the easiest because each nibble maps straight to one hex digit with no arithmetic.

二进制与十进制互转、十六进制与十进制互转、二进制与十六进制互转。二进制与十六进制这一对最简单,因为每个半字节直接对应一个十六进制数字,不需要计算。

Explainer

讲解

Place value in each base

每种进制的位值

In decimal, moving one place left multiplies the value by 10: the digits of 1024 stand for 1000s, 100s, 10s, 1s. Every base works the same way, only the multiplier changes: 2 for binary, 16 for hex.

在十进制里,向左移一位,数值乘以 10:1024 的各位分别代表 1000、100、10、1。每一种进制都是这样,只是乘数不同:二进制是 2,十六进制是 16。

BasePlace values (from the right)Read a digit as
Binary (2)1, 2, 4, 8, 16, 32, 64, 128digit × its place value, then add the results
Hexadecimal (16)1, 16, 256, 4096digit value (A = 10 … F = 15) × its place value, then add
进制位值(从右往左)如何读一位
二进制(2)1、2、4、8、16、32、64、128数字 × 它的位值,再把结果相加
十六进制(16)1、16、256、4096数字的值(A = 10 … F = 15)× 它的位值,再相加

For example, 2F in hex is (2 × 16) + (15 × 1) = 47 in decimal. And 00101010 in binary is 32 + 8 + 2 = 42.

例如,十六进制的 2F 是 (2 × 16) + (15 × 1) = 十进制的 47。而二进制的 00101010 是 32 + 8 + 2 = 42。

Try it yourself

动手试试

Build a byte

拼一个字节

Click the eight bits on and off. The decimal value is the sum of the place values you have switched on. The hex value is the left nibble and the right nibble, each read as one digit.

点击这八个位来开关它们。十进制的值是你打开的那些位值之和。十六进制的值是左半字节和右半字节,各自读成一个数字。

Notice the left nibble only ever affects the first hex digit and the right nibble only the second. That independence is what makes binary and hex quick to convert between.

注意左半字节只影响第一个十六进制数字,右半字节只影响第二个。正是这种互不影响,让二进制和十六进制之间的转换很快。

Worked example

例题

Decimal to binary, then binary to hex

十进制到二进制,再到十六进制

Converting the decimal number 202 with the subtraction method. Work along the place values from the largest: if it fits, write a 1 and subtract it; if not, write a 0.

用减法把十进制数 202 转换过来。从最大的位值开始,沿着位值往右做:如果放得下,写 1 并减掉它;放不下就写 0。

Check your understanding

检验你的理解

What is the hexadecimal number AC written as an 8-bit binary number?

十六进制数 AC 写成 8 位二进制数是多少?

Common mistake

常见错误

Recurring slips in base conversion 进制转换中反复出现的错误

RecurringSeeing 11111111 and answering 256. There are 256 different patterns in 8 bits, but the largest value is 255, because one of those patterns is 00000000. A second slip: in the divide-by-2 method for decimal to binary, the remainder from the very first division belongs at the right-hand end of the answer, so the column of remainders is read from the bottom of the working upward.

反复出现看到 11111111 就答 256。8 个位共有 256 种不同的组合,但最大的值是 255,因为其中一种组合是 00000000。第二个错误:用除法把十进制转二进制时,第一个余数是最低有效位(最右边那位),所以余数要从下往上读,而不是从上往下。

✕

Wrong: "11111111 is the biggest 8-bit number, and 2 to the power 8 is 256, so it equals 256."

错误: "11111111 是最大的 8 位数,2 的 8 次方是 256,所以它等于 256。"

✓

Right: "11111111 is 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255. Eight bits give 256 patterns, from 00000000 to 11111111, so the count of values is 256 but the largest value is 255."

正确: "11111111 是 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255。8 个位给出 256 种组合,从 00000000 到 11111111,所以值的数量是 256,但最大的值是 255。"

Revision questions

复习题

Specimen-paper style. Write an answer, then reveal the marking points and mark yourself.

采用样卷风格。写下答案,然后展开评分要点给自己打分。

Question 1 · 1 mark 第 1 题 · 1 分

[1]State the denary (decimal) value of the binary number 01011010.

[1]写出二进制数 01011010 的十进制值。

Question 2 · 2 marks 第 2 题 · 2 分

[2]Convert the hexadecimal number 7E to an 8-bit binary number, showing your working.

[2]把十六进制数 7E 转换成 8 位二进制数,写出过程。

Question 3 · 2 marks 第 3 题 · 2 分

[2]Convert the decimal number 156 to hexadecimal, showing your working.

[2]把十进制数 156 转换成十六进制,写出过程。

Question 4 · 3 marks 第 4 题 · 3 分

[3]Explain why hexadecimal is used by programmers to represent binary values, rather than writing the binary out in full.

[3]解释为什么程序员用十六进制来表示二进制值,而不是把二进制完整写出来。

Question 5 · 2 marks 第 5 题 · 2 分

[2]A student writes that the binary number 11110000 equals 240 and the hexadecimal number F0. State whether each is correct and correct any error.

[2]一名学生写道二进制数 11110000 等于 240,十六进制为 F0。分别说明是否正确,并改正任何错误。

Flashcards

记忆卡片

Active recall for this statement’s key terms.

针对本条考纲陈述关键术语的主动回忆练习。

Prototype render · grounded in the IB CS 2027 subject guide, the specimen papers and the Hodder and Oxford IB CS 2027 texts for A1.2.1 · not yet wired to live routes