← 返回资讯屏轩教育 · 行业资讯

Data Representation: Key Points for IB & OCR | IB OCR 计算机:数据表示考点精讲

2026-07-14 21:41 · 本文部分内容由AI辅助创作

📚 Data Representation: Key Points for IB & OCR | IB OCR 计算机:数据表示考点精讲

In both IB Computer Science and OCR specifications, data representation forms the bedrock of understanding how computers store, process, and communicate information. From binary digits to complex image encodings, grasping these concepts is essential for any aspiring computer scientist. This article covers the core topics you need to master, from number systems to compression techniques.

在IB计算机科学和OCR考试大纲中,数据表示是理解计算机如何存储、处理和传输信息的基础。从二进制数字到复杂的图像编码,掌握这些概念对每一个计算机科学学习者都至关重要。本文涵盖了你必须掌握的核心主题,从数制到数据压缩技术。

1. Introduction to Data Representation | 数据表示简介

All data inside a modern computer is stored and transmitted as sequences of binary digits (bits), represented by the states 0 and 1. This abstraction allows us to represent numbers, text, images, sound, and instructions using only two voltage levels or magnetic orientations. The fundamental unit is the bit, and 8 bits make up one byte, which is the smallest addressable unit in most architectures.

现代计算机中的所有数据都以二进制数字(比特)序列的形式存储和传输,用0和1两种状态表示。这种抽象使我们能够仅使用两种电压水平或磁化方向来表示数字、文字、图像、声音和指令。基本单位是比特,8个比特组成一个字节,这是大多数体系结构中最小的可寻址单元。

1024 bytes, while a kilobyte (kB) is sometimes used to mean 1000 bytes in storage marketing, but in computing it is crucial to distinguish between decimal and binary prefixes. The standard binary prefixes include mebibyte (MiB, 2²⁰), gibibyte (GiB, 2³⁰), and tebibyte (TiB, 2⁴⁰).

重要的存储单位基于2的幂。一个kibibyte (KiB) 是2¹⁰ = 1024字节,而kilobyte (kB) 在存储产品营销中有时指1000字节,但在计算中区分十进制和二进制前缀至关重要。标准的二进制前缀包括mebibyte (MiB, 2²⁰)、gibibyte (GiB, 2³⁰)和tebibyte (TiB, 2⁴⁰)。


2. Binary Number System | 二进制数系统

The binary system is a base‑ 101₂ represents (1 × 2³) + (1 × 2²) + (0 × 2¹) + (1 × 2⁰) = 8 + 4 + 0 + 1 = 13 in denary (base‑10).

二进制系统是以2为基数的位置记数系统。每个数字(比特)的位值是2的幂,从右向左递增。例如,二进制数1101₂表示 (1 × 2³) + (1 × 2²) + (0 × 2¹) + (1 × 2⁰) = 8 + 4 + 0 + 1 = 13(十进制)。

To avoid ambiguity, we often denote bases using subscripts: 1010₂ (binary), 1010₁₀ (denary), and 1010₁₆ (hexadecimal). Understanding place values is the first step towards mastering conversions and arithmetic.

为了避免歧义,我们通常用下标表示基数:1010₂(二进制)、1010₁₀(十进制)和1010₁₆(十六进制)。理解位值是掌握转换和算术的第一步。


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

the results. For 101101₂: (1×32) + (0×16) + (1×8) + (1×4) + (0×2) + (1×1) = 32+8+4+1 = 45.

要将二进制整数转换为十进制,将每位乘以其位值(2的幂)并求和。对于101101₂:(1×32) + (0×16) + (1×8) + (1×4) + (0×2) + (1×1) = 32+8+4+1 = 45。

ttom (most significant bit) to top (least significant bit). Example: 45 → 22 remainder 1, 11 rem 0, 5 rem 1, 2 rem 1, 1 rem 0, 0 rem 1. Reading upwards gives 101101₂.

要将十进制转换为二进制,反复将十进制数除以2,记录每一步的余数(0或1)。从下往上读余数(最高有效位到最低有效位)。示例:45 → 22 余 1,11 余 0,5 余 1,2 余 1,1 余 0,0 余 1。向上读得101101₂。


4. Hexadecimal System | 十六进制系统

Hexadecimal (hex) is a base‑16 system using digits 0‑9 and letters A (10) to F (15). It is widely used in computing as a more compact representation of binary values. One hex digit corresponds exactly to 4 bits (a nibble), making conversions straightforward. For instance, 1011 1101₂ can be split into nibbles B (1011) and D (1101), giving BD₁₆.

十六进制(hex)是以16为基数的表示法,使用数字0‑9和字母A(10)到F(15)。它广泛应用于计算机中,作为二进制值的更紧凑表示。一个十六进制数字恰好对应4个比特(一个半字节),使得转换很简单。例如,1011 1101₂可分为半字节B(1011)和D(1101),得到BD₁₆。

must be comfortable converting among binary, denary, and hex for numbers up to at least 2 bytes.

要将十六进制转换为十进制,将每位数字乘以16的幂。2F₁₆ = (2×16¹) + (15×16⁰) = 32+15 = 47。在考试中,你必须能熟练地在二进制、十进制和十六进制之间转换至少2字节以内的数字。


5. Binary Arithmetic & Overflow | 二进制运算与溢出

le bits, you may need to propagate carries. Subtraction can be performed by adding the two's complement (covered later).

二进制加法遵循与十进制类似的规则:0+0=0,0+1=1,1+0=1,1+1=0进位1。在多位相加时,可能需要进行进位传播。减法可通过加上补码(稍后介绍)来实现。

Overflow occurs when the result of an addition exceeds the maximum value that can be stored in the given number of bits. For unsigned 8‑bit numbers, adding 1111 1111₂ (255) and 0000 0001₂ (1) yields 1 0000 0000₂, which requires 9 bits; the carry out of the most significant bit indicates an overflow, and the stored result (0000 0000₂) is incorrect.

当加法结果超出给定位数能存储的最大值时会发生溢出。对于无符号8位数字,将1111 1111₂ (255)与0000 0001₂ (1)相加得到1 0000 0000₂,需要9位;最高有效位产生进位表示溢出,存储的结果(0000 0000₂)是不正确的。


广告 / Sponsored

6. Negative Numbers: Two's Complement | 负数:补码表示

In two' t representation, the most significant bit (MSB) is given a negative place value. For an 8‑ dition circuitry works for both positive and negative numbers, and there is only one representation for zero.

在补码表示法中,最高有效位(MSB)被赋予负的位值。对于8位数字,位值为:−128 (MSB)、64、32、16、8、4、2、1。例如,1111 1110₂ = −128+64+32+...+2 = −2。其优点是,相同的加法电路可以同时处理正数和负数,并且零只有一种表示形式。

To find the two's complement negation of a number: invert all bits (one' 1010₂ = −128+64+32+16+8+2 = −6. This method allows a range of −2ⁿ⁻¹ to 2ⁿ⁻¹−1 for n bits.

求一个数的补码负数:将所有位取反(反码)再加1。例如,从6 (0000 0110₂)求−6:取反→1111 1001₂,加1→1111 1010₂ = −128+64+32+16+8+2 = −6。对于n位,此方法允许的范围是−2ⁿ⁻¹到2ⁿ⁻¹−1。


7. Character Encoding (ASCII & Unicode) | 字符编码(ASCII和Unicode)

Computers represent text by mapping each character to a unique binary number. The American Standard Code for Information Interchange (ASCII) uses 7 bits to encode 128 characters, including uppercase and lowercase English letters, digits, punctuation, and control codes. Extended ASCII uses 8 bits for 256 characters, including accented letters and symbols.

计算机通过将每个字符映射到一个唯一的二进制数来表示文本。美国信息交换标准代码(ASCII)使用7位编码128个字符,包括大写和小写英文字母、数字、标点符号和控制码。扩展ASCII使用8位编码256个字符,包含带重音符号的字母和特殊符号。

Unicode was developed to support all writing systems worldwide. It can use up to 32 bits per character, though common encoding forms like UTF‑8 use a variable number of bytes (1 to 4). UTF‑8 is backward compatible with ASCII for the first 128 code points, making it the dominant encoding on the web. The key exam point is understanding how codes are assigned and why standardised encoding is necessary for interoperability.

Unicode是为支持全球所有书写系统而开发的。每个字符最多可使用32位,但常见的编码形式如UTF‑8使用可变字节数(1到4)。UTF‑8在前128个码点与ASCII向后兼容,使其成为网络上的主导编码。考试关键点是理解如何分配码点以及为什么标准化编码对于互操作性是必需的。


8. Representing Images | 图像表示

Images can be represented as bitmaps (raster graphics) or vectors. In a bitmap, the picture is divided into a grid of pixels. Each pixel's colour is stored as a binary value; the colour depth determines how many bits per pixel and thus the number of distinguishable colours. With 1 bit per pixel, only black and white are possible. 8 bits per pixel allows 256 colours, and 24 bits (true colour) gives about 16.7 million colours using 8 bits for each of red, green, and blue components.

图像可以表示为位图(光栅图形)或矢量图。在位图中,图片被划分为像素网格。每个像素的颜色存储为二进制值;颜色深度决定了每个像素的位数,从而决定了可区分的颜色数量。每像素1位只能表示黑白。每像素8位可表示256种颜色,而24位(真彩色)通过对红、绿、蓝分量各使用8位,可提供约1670万种颜色。

(in bits) can be estimated as: width × height × colour depth. A 100×100 pixel image at 24‑ s file headers, camera settings, and GPS coordinates) will further increase the file size.

图像文件大小(以位为单位)可以估算为:宽度 × 高度 × 颜色深度。一幅100×100像素的24位彩色图像需要100×100×24 = 240,000位 = 30,000字节(约29.3 KiB)。元数据(如文件头、相机设置和GPS坐标)还会进一步增加文件大小。


9. Representing Sound | 声音表示

Sound is an analogue signal that must be converted to digital form via sampling. The amplitude of the sound wave is measured at regular intervals (sampling rate) and quantised to a finite number of binary values (bit depth). The Nyquist theorem states that the sampling rate must be at least twice the highest frequency present in the signal to accurately reconstruct it.

声音是一种模拟信号,必须通过采样转换为数字形式。声波的振幅以固定的间隔(采样率)被测量,并量化为有限数量的二进制值(位深度)。奈奎斯特定理指出,采样率必须至少是信号中最高频率的两倍才能准确重建。

16 bits), number of channels (1 for mono, 2 for stereo), and duration in seconds. For a 3‑minute stereo track at 44.1 kHz and 16‑ ts ≈ 30.3 MB. Higher sample rates and bit depths improve fidelity but demand more storage.

音频文件大小取决于:采样率(例如CD音质的44,100次/秒)、位深度(例如16位)、声道数(单声道1个,立体声2个)和持续时间(秒)。对于一首3分钟、44.1 kHz、16位的立体声曲目:大小 = 3 × 60 × 44,100 × 16 × 2 ≈ 2.54亿位 ≈ 30.3 MB。更高的采样率和位深度可提高保真度,但需要更多存储空间。


10. Data Compression: Lossy vs Lossless | 数据压缩:有损与无损

Compression reduces file size to save storage space and transmission bandwidth. Lossless compression extracts redundancy and allows the original data to be perfectly reconstructed. Techniques include run‑length encoding (RLE), where a repeated value is replaced by a count and the value, and dictionary methods like LZW. Lossless is essential for text, executables, and archival data.

压缩可减少文件大小,以节省存储空间和传输带宽。无损压缩去除冗余,并允许完美重建原始数据。技术包括行程编码(RLE),将重复的值替换为一个计数和该值,以及字典方法如LZW。无损压缩对于文本、可执行文件和归档数据至关重要。

Lossy compression discards some data that is less perceptually important, achieving much smaller files but with no perfect reconstruction. It is commonly used for images (JPEG), audio (MP3), and video (MPEG). JPEG exploits the eye's lower sensitivity to colour detail than brightness, while MP3 removes frequencies that are masked by louder sounds. The trade‑off between quality and file size is a key design consideration.

有损压缩丢弃一些感知上不太重要的数据,大幅减小文件大小,但无法完美重建。它通常用于图像(JPEG)、音频(MP3)和视频(MPEG)。JPEG利用人眼对颜色细节的敏感度低于亮度的特点,而MP3则删除被更响声音掩蔽的频率。质量与文件大小之间的权衡是关键的设计考虑因素。


Published by TutorHao | Computer Science Revision Series | aleveler.com

广告 / Sponsored
IBDP国际文凭计算机科学学生用书 高级及标准水平 Computer Science for the IB Diplo…
计算机 备考教辅 · 正版现货 · 与本文内容相关
查看详情 / View on Taobao参考价 ¥524.0

更多咨询请联系16621398022(同微信)

备考资讯每日更新,关注不错过
考纲变化 · 科目分析 · 学习方法
扫码关注公众号 tutorhao
在微信里长按二维码识别关注
或截图后用「扫一扫 → 相册」选择本图
公众号:tutorhao