AQA计算机科学 进制转换 图像 声音 压缩
GCSE 计算机科学里最像数学题的一块是数据表示。AQA 的 8525 把三种进制、数据单位、二进制加法与移位、字符编码、图像与声音的存储、压缩全部放在 3.3 这一章,题目给分靠写出来的步骤,不靠最后的结论。下面按官方 spec(AQA 8525,2020 年 9 月起施教、2022 年首次考试)的条目顺序,把十二个考点的算法、单位与阅卷口径写成可以直接照做的算例。
Data representation is the part of GCSE Computer Science that behaves like a maths topic, since a small set of rules is applied under time pressure; the marks are earned by the working, not by the final value. Every one of these marks sits on Paper 2, and the work is narrow in scope, covering base conversion, file sizing and reading a compression method off a diagram or a table.
一、卷面位置:数据表示的分数在 Paper 2
8525 是线性资格,所有卷子都在课程结束时考,没有计入成绩的课程作业。Paper 1 考算法与编程,2 小时 90 分占一半,Paper 2 考 Computing concepts,1 小时 45 分钟 90 分占一半,直接覆盖 3.3 到 3.8,数据表示就是 3.3 整章。两卷合计 180 分,编程语言从 C#、Python 3、VB.NET 里挑一种,AQA 更新后的 spec 仍然保留这三门语言。很多学生以为二进制只在编程题里出现,其实 3.3 的算分点全部落在 Paper 2 的换算与计算题上,Paper 1 只是间接用到位模式。阅卷时这一章丢分最集中的位置是中间步骤与单位,只写结果不写换算过程通常拿不到过程分。
Every data representation mark sits on Paper 2, which carries 90 marks over 1 hour 45 minutes and covers sections 3.3 to 3.8; Paper 1 lasts two hours and assesses algorithms and programming, so it uses bit patterns without ever asking you to convert one. The qualification is linear, meaning all exams are sat at the end of the course and no coursework counts towards the grade; three languages are supported, namely C#, Python 3 and VB.NET. Markers lose more marks in this chapter on dropped working and missing units than on wrong values.
二、三种进制与八位位值
十进制用十个数码,二进制只有 0 与 1,十六进制用 0 到 9 再加 A 到 F,其中 A 代表 10,F 代表 15。一个二进制位叫 bit,四位叫 nibble,八位叫 byte,一个字节的位值从左到右是 128、64、32、16、8、4、2、1。8525 要求把 0 到 255 之间的十进制数写成二进制与十六进制,spec 写明的对照是十进制 255、二进制 1111 1111、十六进制 FF。把 01001101 读成十进制,只要把 1 所在的那几列相加,64 加 8 加 4 加 1 等于 77。反过来把 200 写成二进制,依次减去装得下的最大位值,128 加 64 加 8 得到 11001000。很多学生以为这题必须从左到右一格一格数完,其实先看 1 的分布再相加最快。
Binary uses two symbols and hexadecimal uses sixteen, so A stands for 10 and F for 15; four bits make a nibble, while eight bits make a byte with place values 128, 64, 32, 16, 8, 4, 2 and 1. The specification fixes the working range at 0 to 255, which makes 255, 1111 1111 and FF an exact equivalence worth memorising. Reading 01001101 means adding 64, 8, 4 and 1 to get 77, while writing 200 means subtracting 128, then 64, then the 8.
三、三种互转与 255 这个上限口径
AQA 要求三个方向都能互转:二进制与十进制、二进制与十六进制、十进制与十六进制,最大值口径统一写成十进制 255、二进制 1111 1111、十六进制 FF。二进制与十六进制之间的转换最快,把一个字节从中间切成两个 nibble,1001 1100 就是 9 与 C,合起来 9C。十进制转十六进制用除以 16 的方法,156 除以 16 得 9 余 12,12 写作 C,答案就是 9C,验算时 9 乘 16 加 12 正好回到 156。十六进制转十进制用 16 与 1 两个位值,2F 等于 2 乘 16 加 15,即 47。常见的错误是切 nibble 时从左边开始补空位,正确做法是右对齐,不够四位时在前面补 0。
Conversions run in all three pairings, and the stated ceiling is decimal 255, binary 1111 1111 and hexadecimal FF; the fastest route between binary and hex is splitting a byte into two nibbles. So 1001 1100 becomes 9 and C to give 9C, which checks as 156 when multiplied back out, while decimal to hex uses division by 16 with the remainder written as a digit. A common slip is padding the wrong end of a nibble, so keep the bits right-aligned and fill the front with zeros.
四、十六进制为什么在计算机科学里常用
spec 明确要求解释十六进制为什么常用,最核心的一条是它的一位刚好对应四位二进制,一个字节永远是两位十六进制。这样写出来的数字短、抄写不容易出错,人也更容易核对内存地址、颜色值这类长位串。同样一个字节,用二进制要写八位,比如 1111 1111,用十六进制只要 FF 两个字符,长度是原来的四分之一。反过来说,看到 FF 能立刻判断它是 255,因为 F 是 15,两个 F 就是 15 乘 16 加 15。学生最常把十六进制当成另一种十进制,转换时就忘记 16 这个位值。答题时把两个理由写全:表达更短,且四位一组与人习惯的读取单位对齐。
Hexadecimal is used because one digit maps exactly onto four bits, so a byte is always written as two hex digits; that makes long bit strings shorter and far harder to misread or mistype. A byte needs eight characters in binary such as 1111 1111, but only FF in hex, which is a quarter of the length, and FF is easy to read as 255 once F is known to be 15. The usual mistake is treating hex as decimal, which loses the place value of 16 the moment a conversion starts.
五、数据单位与十进制前缀
数据量从最小单位往上数:bit 是最基本的单位,一个 byte 是 8 位,bit 的符号是小写 b,byte 的符号是大写 B,这两个符号混用会直接丢分。8525 用的是十进制前缀,1 kB 等于 1000 字节,1 MB 等于 1000 kB,1 GB 等于 1000 MB,1 TB 等于 1000 GB,每一步都乘 1000。历史上 kilobyte 常被当成 1024 字节使用,AQA 的口径是十进制,所以 256 MB 就是 256000000 字节,不能按 1024 去算。很多学生以为 KB 与 kB 只是大小写差别,实际上题目里写 b 是位、写 B 是字节,50 Mb 与 50 MB 相差八倍。比较两个数的大小时,先把单位化成同一级再比,这一步在选择题里最省时间。
Storage units build up from the bit, which is the fundamental unit, to the byte of eight bits; the lowercase b means bit and the uppercase B means byte, and mixing them up costs marks immediately. The prefixes are decimal in this specification, so 1 kB is 1000 bytes and each later step multiplies by 1000 again up to the terabyte. Historically kilobyte was often used for 1024 bytes, but 256 MB here means 256000000 bytes, and comparing two quantities means converting to the same unit first.
六、二进制加法与溢出
spec 允许最多三个二进制数相加,每个数最多 8 位,同一列最多出现三个 1,答案不会超过 8 位,也不会用到第八位之后的进位。加法的四条规则是 0 加 0 得 0、0 加 1 得 1、1 加 1 得 0 并向前进 1、1 加 1 加 1 得 1 并向前进 1。算 00110101 加 00010011,从最右一列开始逐列处理,结果是 01001000,换成十进制就是 53 加 19 等于 72。溢出出现在需要超过 8 位才装得下的结果上,例如 11111111 加 1 需要第九位,多出来的那一位被丢掉,剩下的值就不再正确。这一步最容易出现的问题是连续进位处理错,前一列的进位补进来以后会变成三个 1 相加。
Up to three binary numbers may be added, each held in 8 bits, and no column will ever contain more than three ones; the carry rules are that one plus one gives zero with a carry, and one plus one plus one gives one with a carry. Adding 00110101 to 00010011 gives 01001000, which is 53 plus 19 in denary, and the columns are worked from the right. Overflow happens when a result needs a ninth bit, so 11111111 plus 1 loses the extra bit and stores a value that is no longer correct.
七、逻辑移位:左移乘 2,右移除 2
AQA 只要求逻辑移位,不考虑小数表示。左移一位等于乘 2,左移两位等于乘 4,移位 n 位就是乘 2 的 n 次方。00001010 是十进制 10,左移一位变成 00010100,也就是 20。右移一位等于整除 2,48 右移两位等于 12。移出边界的位会丢失,所以右移奇数时会损失精度,5 右移一位得 2 而不是 2.5,因为小数表示不在 8525 的范围内。spec 还要求说明移位能做什么:它对应简单的乘除 2 的幂运算,处理位模式或者做快速缩放时很常用。阅卷时这一节的分通常一半给结果,一半给移出的位会丢失这个说明。
Only logical shifts appear in this specification, with fractional representations left out, so a left shift multiplies and a right shift divides; shifting by n places multiplies or divides by two to the power of n. So 00001010 is 10 and becomes 00010100, or 20, after one shift left, while 48 shifted right twice is 12. Bits pushed off the end are lost, which is why an odd number loses precision and why the exam expects a sentence explaining that shift operations perform multiplication and division by powers of two.
八、字符编码:7 位 ASCII 与 Unicode
字符集是一张把字符映射到二进制码的表,8525 要求掌握 7 位 ASCII 与 Unicode 两种。7 位 ASCII 有 128 个码位,够写英文大小写字母、数字与标点,但覆盖不了中文、日文这类文字系统。Unicode 用的位数更多,能表示世界上大部分文字系统与表情符号,代价是每个字符占的空间更大。编码表里的码值连续排列:大写 A 是 65,B 就是 66,C 是 67,小写 a 是 97,数字 0 是 48,知道起点就能推算整组。考试会给一张编码表,要求把字符转成码、把码转回字符,做法是先定位分组再数偏移。很多学生以为 Unicode 是一种压缩方法,其实它正好相反,它比 ASCII 占的空间更大。
A character set is a table mapping characters to binary codes, and the two methods to know are 7 bit ASCII and Unicode; ASCII gives 128 codes, which is enough for English letters, digits and punctuation but not for other writing systems. Unicode uses more bits per character and covers most of the world's scripts along with emoji, at the cost of more storage for each character. Codes run in sequence within a group, so A at 65 makes B 66 and C 67, and a given table lets you count the offset rather than memorise every value.
九、位图:像素、图像尺寸与色彩深度
位图由像素组成,pixel 是 picture element 的缩写,一个像素是图像里的一个点。图像尺寸写成宽乘高,单位是像素,比如 200 乘 400 表示横向 200 列、纵向 400 行。色彩深度是每个像素用多少位表示,1 位给出 2 种颜色,8 位给出 256 种,16 位给出 65536 种,24 位给出 16777216 种,每加一位颜色数就翻一倍。像素数变多或者色彩深度变大,文件都会变大,因为每个像素要多存一些位。spec 还给了一个反向任务:给出简单位图的二进制模式要能画出像素图,反过来也要能把图写成二进制。常见的错误是把色彩深度当成颜色总数,深度 8 指的是每个像素 8 位,不是 8 种颜色。
A bitmap is built from pixels, where pixel is short for picture element and stands for a single point in the image; image size is written as width by height in pixels. Colour depth is the number of bits used per pixel, so one bit gives two colours, eight bits give 256 and sixteen bits give more than sixty five thousand, with every extra bit doubling the range. More pixels or a greater colour depth both increase file size, and the specification also expects you to draw a simple bitmap from a binary pattern and to write one out as bits.
十、图像文件大小计算
位图大小的公式是宽度乘高度乘色彩深度,算出的是位数,要除以 8 才变成字节。8525 的附加信息写明 W 是宽、H 是高、D 是以位为单位的色彩深度,计算只用像素数与色彩深度这两个量。算一张 200 乘 400、色彩深度 16 的图,200 乘 400 等于 80000 个像素,再乘 16 得到 1280000 位,除以 8 是 160000 字节,按十进制前缀就是 160 kB。把色彩深度换成 24 位,同样像素数的文件变成 1920000 位、240000 字节,也就是 240 kB,深度每加一位文件就多 80000 位。这一步最容易漏掉除以 8,题目问字节时答案会差 8 倍。图像文件里还存着宽高与色彩深度这类描述自身的数据,读取时靠它们才能正确还原画面,但计算题只要求用像素数与色彩深度。
Bitmap size in bits is width times height times colour depth, and the result is divided by eight to reach bytes; the specification labels these as W, H and D, with D measured in bits per pixel. A 200 by 400 image at a depth of 16 gives 80000 pixels, then 1280000 bits, then 160000 bytes, which is 160 kB under decimal prefixes, while raising the depth to 24 bits takes the same image to 240 kB. The step most often dropped is the division by eight, and the metadata stored with the file is not needed for the calculation.
十一、声音:采样率与采样分辨率
声音在自然界里是连续变化的模拟信号,存进计算机之前必须先采样,采样就是在某个时刻测一次波的振幅。采样率是一秒钟采多少个点,单位是赫兹,1 赫兹等于每秒 1 个采样点,采样分辨率是每个点用多少位存,位数越多还原出来的细节越接近原声。声音文件的位数等于采样率乘采样分辨率乘秒数,再把位数除以 8 换成字节。举个能照抄的数字:采样率 44100 赫兹、分辨率 16 位、时长 30 秒,得到 21168000 位,也就是 2646000 字节,约 2.65 MB。把采样率降到 8000 赫兹、分辨率降到 8 位、时长 60 秒,文件只有 3840000 位、480 kB,文件小了但音质明显下降。学生最常把采样率与采样分辨率混为一谈,前者是每秒多少个点,后者是每个点多少位。
Sound is analogue and has to be sampled before storage, where a sample records the amplitude of the wave at a point in time; the sampling rate counts samples per second in hertz, and the sample resolution gives the bits per sample. File size in bits is rate times resolution times seconds, so 44100 Hz at 16 bits for 30 seconds gives 21168000 bits, or about 2.65 MB in bytes. Dropping to 8000 Hz at 8 bits for 60 seconds gives 3840000 bits, a much smaller file with clearly worse quality.
十二、压缩:RLE 与 Huffman,以及 2027 年的考纲口径
压缩的目的是让文件占更少存储、传输更快,分有损与无损两类,有损压缩永久丢掉一部分数据,JPEG 与 MP3 属于这一类,无损压缩能完整还原原文件。RLE 用频次对存放数据,把连续的相同值写成一个数字加一个值,例如 AAAAAABBB 写成 6A3B,用四个字符代替原来的九个字符。Huffman 编码给出现频率高的字符分配短的码,频率低的给长码,读法是从 Huffman 树按分支一路走到目标字符,再数一共用掉多少位。压缩的收益可以直接算出来:200 个字符用 7 位 ASCII 存需要 1400 位,换成平均 4 位的 Huffman 码只要 800 位,省下 600 位也就是 75 字节。AQA 在 2025 年公布的更新里把 3.3.7 的一句措辞删掉,新 spec 从 2025 年 9 月起施教、2027 年首次考试,数据表示的计算口径本身没有变化。
Compression shrinks files so they take less storage and transmit faster, and the two families are lossy, which throws data away permanently as JPEG and MP3 do, and lossless, which rebuilds the original exactly. Run length encoding is lossless and stores a count with each value, so AAAAAABBB becomes 6A3B and nine characters shrink to four. Huffman coding gives frequent characters shorter codes read from a tree, and 200 characters take 1400 bits in 7 bit ASCII but 800 bits at an average of four bits, saving 600 bits or 75 bytes.
戴睿(dere)Neo优选系列 创意双触摸屏高性能笔记本电脑大学生AI学习商务办公设计炒股娱乐手提轻薄本32/1TB¥4586.0📱 去京东购买京东精选
需要一对一辅导?Need One-on-One Tutoring?
A-Level / GCSE / IB / KS2-KS3 全科辅导
16621398022 同微信
Visit aleveler.com
或截图后用「扫一扫 → 相册」选择本图