給教育者: 為 Data representation(Information and Communication Technology、Information Processing)準備好可直接使用的課程投影片, 複習筆記——用於你的課程,或把這個主題當成互動班級活動,讓學習者以即時遊戲的方式進行。
Analog data changes continuously and can take any value in a range, e.g. temperature, sound waves, a clock with hands.
模擬數據會連續地變化,可以是某範圍內的任何數值,例如溫度、聲波、有指針的時鐘。
Digital data has discrete (separate) values, stored in a computer as binary digits (bits) 0 and 1.
數碼數據只有離散(分開)的數值,在電腦中以二進制數位(位元)0 和 1 儲存。
An analog-to-digital converter (ADC) is needed to input analog data, e.g. recording voice with a microphone. A digital-to-analog converter (DAC) is needed to output it, e.g. playing music through speakers.
Subtraction: to subtract B, add the two's complement of B instead; ignore any carry out of the leftmost bit.
減法:要減去 B,改為加上 B 的二補數;忽略最左位元進出的進位。
Overflow happens when a result is too large (or too small) to fit in the number of bits available, so the stored result is wrong.
當結果太大(或太小)而無法容納於可用的位元數時便會出現溢出,令儲存的結果錯誤。
Example with 8-bit two's complement: 90 + 55 gives 145, which is more than 127, so 01011010 + 00110111 gives 10010001 — read as -111, an overflow error.
Tip: in two's complement, adding two positives that gives a negative (or two negatives that gives a positive) means overflow.
提示:在二補數中,兩個正數相加得負數(或兩個負數相加得正數)即表示溢出。
Character sets 字元集
A character set gives each character a unique binary code so text can be stored and exchanged.
字元集為每個字元指定一個獨特的二進制編碼,使文字可以儲存及交換。
ASCII: 7 bits (128 characters) for English letters, digits and symbols, e.g. 'A' is 65, 'a' is 97, '0' is 48. Codes are in order, so if 'C' is 67 then 'F' is 70.
Big-5: 2 bytes per character, for Traditional Chinese (used in Hong Kong and Taiwan). GB code (e.g. GB2312): 2 bytes per character, for Simplified Chinese (mainland China).
Unicode (e.g. UTF-8, UTF-16) covers characters of almost all languages plus emoji, so one document can mix English, Chinese and Japanese without garbled text (亂碼).
A bitmap image is a grid of pixels; each pixel stores a colour as a binary number.
點陣圖由像素組成的格子構成;每個像素以二進制數儲存一種顏色。
Resolution is the number of pixels (e.g. 1920 × 1080). Colour depth is the bits per pixel: 1 bit gives 2 colours, 8 bits give 256, 24 bits give about 16.7 million.
Higher resolution or colour depth gives better quality but a larger file.
解像度或色彩深度越高,質素越好,但檔案越大。
Digitising audio and video 聲音及視像數碼化
Sound is sampled: the ADC measures the wave's amplitude many times a second. Sampling rate is samples per second (e.g. 44.1 kHz); bit depth (sample size) is bits per sample (e.g. 16 bits).
Higher sampling rate and bit depth give more accurate sound but larger files.
取樣率及位元深度越高,聲音越準確,但檔案越大。
Video is a sequence of images (frames) shown quickly, e.g. 30 frames per second, usually with audio; it is almost always compressed.
視像是快速顯示的一連串圖像(幀),例如每秒 30 幀,通常附有聲音;幾乎總是經過壓縮。
Compression and file formats 壓縮與檔案格式
Lossless compression reduces size with no loss of data (e.g. png, zip). Lossy compression removes data people hardly notice, giving much smaller files (e.g. jpg, mp3, mpeg4).
Images: bmp (uncompressed bitmap), png (lossless, supports transparency, good for diagrams/logos), jpg (lossy, good for photos).
圖像:bmp(未壓縮點陣圖)、png(無損、支援透明、適合圖解及標誌)、jpg(有損、適合相片)。
Audio: wav (usually uncompressed, high quality, large), mp3 (lossy, small, for music streaming/players).
聲音:wav(通常未壓縮、高質素、檔案大)、mp3(有損、檔案小、用於串流及播放器)。
Video: avi (container, often large), mpeg4 / mp4 (compressed, widely used online).
視像:avi(容器格式,通常較大)、mpeg4/mp4(已壓縮,網上廣泛使用)。
Documents: txt (plain text, no formatting), docx (Microsoft Word), odt (OpenDocument, open standard), pdf (fixed layout that looks the same on any device).
10.Why do programmers often write binary values in hexadecimal? 為何程式員常以十六進制書寫二進制值?
Medium
AHexadecimal uses less memory in the computer 十六進制在電腦中佔用較少記憶體
BIt stops overflow errors 它可防止溢出錯誤
CThe CPU can only process hexadecimal CPU 只能處理十六進制
DIt is shorter and easier for people to read and write 它較短,較易讓人閱讀和書寫
11.What is -45 in 8-bit two's complement? -45 的 8 位元二補數是甚麼?
Medium
A10101101
B11010010
C11010011
D00101101
12.What denary value does the 8-bit two's complement number 10000000 represent? 8 位元二補數 10000000 代表哪個十進制值?
Medium
13.What is the range of integers that can be represented in 8-bit two's complement? 8 位元二補數可表示的整數範圍是甚麼?
Medium
A0 to 255 0 至 255
B-127 to 127 -127 至 127
C-128 to 127 -128 至 127
D-256 to 255 -256 至 255
14.In two's complement, a number whose leftmost bit is 1 is negative. 在二補數中,最左位元是 1 的數是負數。
Easy
True or false?
15.What is the result of the binary addition 01011010 + 00110111 using 8 bits? 二進制加法 01011010 + 00110111(8 位元)的結果是甚麼?
Medium
A10010001
B10010011
C01110001
D10001001
16.If 01011010 + 00110111 is calculated in 8-bit two's complement, what happens? 若以 8 位元二補數計算 01011010 + 00110111,會發生甚麼?
Hard
AAn overflow error occurs because 145 is greater than 127 由於 145 大於 127,出現溢出錯誤
BThe correct answer 145 is stored 儲存正確答案 145
CA parity error occurs 出現奇偶錯誤
DThe result is rounded to 127 結果被調整為 127
17.Using 8-bit two's complement, what is 00010100 - 00001001? 使用 8 位元二補數,00010100 - 00001001 等於甚麼?
Hard
A00001011
B00011101
C11110101
D00001101
18.Which of the following statements about overflow are correct? (1) It occurs when a result is too large for the available bits. (2) Using more bits can avoid it for the same calculation. (3) It can be detected by a parity check. 以下哪些關於溢出的陳述是正確的?(1) 當結果大於可用位元所能容納時便會出現。(2) 對同一運算使用更多位元可避免溢出。(3) 可以用奇偶校驗偵測溢出。
Medium
A(1) only 只有 (1)
B(1) and (2) only 只有 (1) 和 (2)
C(2) and (3) only 只有 (2) 和 (3)
D(1), (2) and (3) (1)、(2) 和 (3)
19.In ASCII, 'A' is 65. What is the ASCII code of 'E'? 在 ASCII 中,「A」是 65。「E」的 ASCII 碼是多少?
Easy
A68
B69
C70
D101
20.Match each character set with its main use. 把每個字元集配對其主要用途。
Easy
ASCII
Big-5 大五碼
GB code 國標碼
Unicode 統一碼
English letters, digits and symbols 英文字母、數字及符號
Traditional Chinese 繁體中文
Simplified Chinese 簡體中文
Almost all languages in one standard 以單一標準涵蓋幾乎所有語言
21.A 500-character Chinese passage is saved using Big-5. About how much storage do the characters need? 一篇 500 字的中文文章以大五碼儲存。字元約需要多少儲存空間?
Medium
A250 bytes 位元組
B500 bytes 位元組
C1000 bytes 位元組
D4000 bytes 位元組
22.Garbled text (亂碼) may appear when a file saved in GB code is opened as Big-5. 以國標碼儲存的檔案若以大五碼開啟,可能出現亂碼。
Medium
True or false?
23.A bitmap image is 1024 × 768 pixels with 24-bit colour and no compression. What is its file size? 一幅點陣圖為 1024 × 768 像素、24 位元色彩,未經壓縮。其檔案大小是多少?
Hard
A0.75 MB
B2.25 MB
C18 MB
D24 MB
24.What happens to an image if its colour depth is reduced from 24 bits to 8 bits? 若圖像的色彩深度由 24 位元減至 8 位元,會怎樣?
Medium
AMore colours can be shown and the file is larger 可顯示更多顏色,檔案更大
BFewer colours can be shown and the file is smaller 可顯示的顏色較少,檔案較小
CThe resolution doubles 解像度增加一倍
DThe image becomes a vector graphic 圖像變成向量圖形
25.A 10-second mono sound clip is recorded at 8000 Hz with 8-bit samples and no compression. What is its size in bytes? 一段 10 秒的單聲道聲音以 8000 Hz、8 位元取樣錄製,未經壓縮。其大小是多少位元組?
Medium
26.Which changes would make a digital audio recording MORE accurate? (Select all that apply) 以下哪些改變會令數碼錄音更準確?(選出所有正確答案)
Medium
AIncreasing the sampling rate 提高取樣率
BIncreasing the bit depth 提高位元深度
CSaving it as mp3 instead of wav 以 mp3 而非 wav 儲存
DReducing the number of samples per second 減少每秒取樣次數
27.Match each file format with its type of data. 把每種檔案格式配對其數據類型。
Easy
mp3
png
mpeg4
odt
Audio 聲音
Image 圖像
Video 視像
Text document 文字文件
28.A school logo with sharp edges and a transparent background will be placed on a web page. Which format is MOST suitable? 一個邊緣清晰、背景透明的學校標誌將放在網頁上。哪種格式最合適?
Medium
Ajpg
Bbmp
Cpng
Dwav
29.Which of the following is a feature of lossy compression? 以下哪項是有損壓縮的特點?
Easy
AThe original file can be restored exactly 可完全還原原始檔案
BThe file size always increases 檔案大小總會增加
CIt is only used for text files 只用於文字檔案
DSome data is permanently removed to make the file much smaller 永久刪除部分數據,令檔案小得多
30.A teacher wants to send an assignment so that it looks exactly the same on every student's device and cannot easily be edited. Which format is MOST suitable? 老師想發送一份在每位學生裝置上看起來完全一樣、且不易被修改的作業。哪種格式最合適?
Easy
Apdf
Bdocx
Ctxt
Dodt
31.A digital camera takes photos of 4000 × 3000 pixels using 24-bit colour. 一部數碼相機拍攝 4000 × 3000 像素、24 位元色彩的相片。 How many pixels does each photo contain? 每張相片有多少個像素?
Medium
A7 000
B12 000
C1 200 000
D12 000 000
32.A digital camera takes photos of 4000 × 3000 pixels using 24-bit colour. 一部數碼相機拍攝 4000 × 3000 像素、24 位元色彩的相片。 How many bytes does an uncompressed photo need? 一張未壓縮的相片需要多少位元組?
Medium
A12 000 000
B24 000 000
C36 000 000
D288 000 000
33.A digital camera takes photos of 4000 × 3000 pixels using 24-bit colour. 一部數碼相機拍攝 4000 × 3000 像素、24 位元色彩的相片。 The camera saves photos as jpg. What is the main reason? 相機以 jpg 格式儲存相片,主要原因是甚麼?
Medium
Ajpg supports animation jpg 支援動畫
Bjpg files are much smaller because of lossy compression jpg 因有損壓縮而檔案小得多
Cjpg keeps every pixel exactly jpg 完全保留每個像素
Djpg is a text format jpg 是文字格式
34.Convert the number. 轉換數值。
Medium
The denary number 200 written in hexadecimal is ____.
35.Name the error that occurs when the result of a calculation is too large to be stored in the available bits. 說出當運算結果太大而無法儲存於可用位元時出現的錯誤名稱。
Easy
36.A digital camera takes photos of 4000 × 3000 pixels using 24-bit colour.
(a) Calculate the number of pixels in each photo. [1]
(b) Calculate the number of bytes needed to store one uncompressed photo. [2]
(c) The camera saves photos in JPEG format. Explain the main reason for using JPEG. [2]
Easy
複習筆記
## Analog vs digital 模擬與數碼
- Analog is continuous; digital is discrete binary. ADC for input, DAC for output. 模擬是連續的;數碼是離散的二進制。輸入用 ADC,輸出用 DAC。
- n bits give 2^n patterns. n 個位元有 2^n 種組合。
## Number systems 數制
- Binary place values 128 64 32 16 8 4 2 1. 二進制位值 128 64 32 16 8 4 2 1。
- One hex digit is 4 bits (A means 10 … F means 15). 一個十六進制數位是 4 個位元。
- Two's complement: invert and add 1; 8-bit range -128 to 127. 二補數:反轉加 1;8 位元範圍 -128 至 127。
- **Overflow**: result too big for the bits. 溢出:結果太大,位元無法容納。
## Character sets 字元集
- ASCII (English), Big-5 (Traditional Chinese), GB (Simplified Chinese), Unicode (all languages). ASCII(英文)、大五碼(繁體)、國標碼(簡體)、統一碼(所有語言)。
## Multimedia 多媒體
- Image bits: width × height × colour depth. 圖像位元:寬 × 高 × 色彩深度。
- Audio bits: sampling rate × sample size × channels × seconds. 聲音位元:取樣率 × 位元深度 × 聲道 × 秒數。
- Lossless: png, zip. Lossy: jpg, mp3, mpeg4. 無損:png、zip;有損:jpg、mp3、mpeg4。
Analog data 模擬數據
Data that varies continuously. 連續變化的數據。
Digital data 數碼數據
Data with discrete values, stored as bits. 具離散數值、以位元儲存的數據。
Hexadecimal 十六進制
Base-16 number system using 0–9 and A–F. 使用 0–9 及 A–F 的十六進制數制。
Two's complement 二補數
A binary method for representing negative integers. 表示負整數的二進制方法。
Overflow 溢出
An error when a result is too large for the available bits. 結果太大、可用位元無法容納時的錯誤。
Character set 字元集
A table giving every character a unique binary code. 為每個字元指定獨特二進制編碼的表。
Unicode 統一碼
A character set covering almost all the world's languages. 涵蓋世界上幾乎所有語言的字元集。
Colour depth 色彩深度
Number of bits used for each pixel. 每個像素所用的位元數。
Sampling rate 取樣率
Number of sound samples taken per second. 每秒聲音取樣的次數。
Lossy compression 有損壓縮
Compression that permanently removes some data. 永久刪除部分數據的壓縮。
字卡
What does an ADC do? ADC 有何作用?
Converts analog signals to digital data. 把模擬訊號轉為數碼數據。
Patterns with n bits? n 個位元有多少種組合?
2n — e.g. 8 bits give 256. 2n——例如 8 位元有 256 種。
8-bit binary place values? 8 位元二進制位值?
128 64 32 16 8 4 2 1
Why use hexadecimal? 為何使用十六進制?
Shorter and easier for humans to read than binary. 比二進制更短、更易閱讀。
How to find -x in two's complement? 如何以二補數求 -x?
Write x in binary, invert all bits, add 1. 把 x 寫成二進制,反轉所有位元,加 1。
8-bit two's complement range? 8 位元二補數範圍?
-128 to 127. -128 至 127。
What is overflow? 甚麼是溢出?
A result too large to fit in the available bits. 結果太大,可用位元無法容納。
Big-5 vs GB? 大五碼與國標碼?
Big-5: Traditional Chinese; GB: Simplified Chinese; both 2 bytes per character. 大五碼:繁體;國標碼:簡體;每字均 2 位元組。