Data representation

플레이하며 배우기

이 문제들을 풀어 에너지를 얻은 뒤 낚시하고 탐험하세요. 계정이 필요 없어요.

교육자를 위해: Data representation(Information and Communication Technology, Information Processing)을(를) 위한 바로 쓸 수 있는 수업 슬라이드, 복습 노트 — 수업에 사용하거나, 학습자들이 실시간 게임으로 즐기는 인터랙티브 클래스 활동으로 진행하세요.

수업 노트

Analog and digital data 模擬數據與數碼數據

  • 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.
  • 輸入模擬數據時需要模擬數碼轉換器(ADC),例如用咪高峰錄音;輸出時需要數碼模擬轉換器(DAC),例如用揚聲器播放音樂。

Why computers use binary 為何電腦使用二進制

  • Electronic circuits have two stable states (on/off, high/low voltage), which map easily to 1 and 0.
  • 電子電路有兩種穩定狀態(開/關、高/低電壓),很容易對應 1 和 0。
  • Two states are reliable and less affected by electrical noise than many levels would be.
  • 兩種狀態較可靠,比多個電壓級別較少受電子雜訊影響。
  • With n bits, there are 2n different patterns: 1 bit gives 2, 4 bits give 16, 8 bits (1 byte) give 256.
  • n 個位元可組成 2n 種不同組合:1 位元有 2 種,4 位元有 16 種,8 位元(1 位元組)有 256 種。
  • To represent 200 different values you need 8 bits, because 27 is only 128 but 28 is 256.
  • 要表示 200 個不同數值需要 8 個位元,因為 27 只有 128,而 28 是 256。

Denary, binary and hexadecimal 十進制、二進制與十六進制

  • Denary (base 10) uses digits 0–9; binary (base 2) uses 0 and 1; hexadecimal (base 16) uses 0–9 and A–F (A means 10 … F means 15).
  • 十進制(基數 10)使用 0–9;二進制(基數 2)使用 0 和 1;十六進制(基數 16)使用 0–9 和 A–F(A 代表 10 … F 代表 15)。
  • Binary place values (8 bits): 128, 64, 32, 16, 8, 4, 2, 1. Example: 00101101 is 32 + 8 + 4 + 1, which is 45.
  • 二進制位值(8 位元):128、64、32、16、8、4、2、1。例子:00101101 是 32 + 8 + 4 + 1,即 45。
  • Denary to binary: subtract the largest place values (or divide by 2 repeatedly and read the remainders upward).
  • 十進制轉二進制:逐一減去最大的位值(或重複除以 2,由下而上讀餘數)。
  • One hex digit is 4 bits. Binary to hex: split into groups of 4 from the right, e.g. 1101 0110 is D6.
  • 一個十六進制數位等於 4 個位元。二進制轉十六進制:由右至左每 4 位一組,例如 1101 0110 即 D6。
  • Hex is used because it is shorter and easier for people to read than binary, e.g. colour codes #FF0000 and memory addresses.
  • 使用十六進制是因為它比二進制更短、更易閱讀,例如顏色代碼 #FF0000 和記憶體位址。

Two's complement 二補數

  • Two's complement represents negative integers. The leftmost bit has a negative place value: in 8 bits it is -128.
  • 二補數用來表示負整數。最左邊的位元的位值是負數:8 位元時為 -128。
  • To find -x: write x in binary, invert all bits, then add 1. Example: 45 is 00101101 → invert 11010010 → add 1 → 11010011 is -45.
  • 求 -x:把 x 寫成二進制,把所有位元反轉,然後加 1。例子:45 是 00101101 → 反轉 11010010 → 加 1 → 11010011 即 -45。
  • If the leftmost bit is 1, the number is negative. For 11111011, add the place values: -128 + 64 + 32 + 16 + 8 + 2 + 1, which gives -5.
  • 若最左位元是 1,該數便是負數。11111011 的位值相加:-128 + 64 + 32 + 16 + 8 + 2 + 1,得 -5。
  • Range of n-bit two's complement: -2^(n-1) to 2^(n-1) - 1. For 8 bits: -128 to 127. Unsigned 8 bits: 0 to 255.
  • n 位元二補數的範圍:-2^(n-1) 至 2^(n-1) - 1。8 位元時為 -128 至 127;無符號 8 位元則為 0 至 255。

Binary arithmetic and overflow 二進制運算與溢出

  • Binary addition rules: 0+0 is 0; 0+1 is 1; 1+1 is 0 carry 1; 1+1+1 is 1 carry 1.
  • 二進制加法規則:0+0 得 0;0+1 得 1;1+1 得 0 進 1;1+1+1 得 1 進 1。
  • 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.
  • 例子,以 8 位元二補數計算:90 + 55 得 145,大於 127,所以 01011010 + 00110111 得 10010001——被讀作 -111,屬溢出錯誤。
  • 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.
  • ASCII:以 7 位元表示 128 個英文字母、數字及符號,例如「A」是 65、「a」是 97、「0」是 48。編碼按次序排列,所以若「C」是 67,「F」便是 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).
  • 大五碼(Big-5):每字 2 位元組,用於繁體中文(香港及台灣使用)。國標碼(GB,例如 GB2312):每字 2 位元組,用於簡體中文(中國內地使用)。
  • 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 (亂碼).
  • 統一碼(Unicode,例如 UTF-8、UTF-16)涵蓋幾乎所有語言的字元及表情符號,因此同一文件可混合英文、中文及日文而不會出現亂碼。

Digitising images 圖像數碼化

  • 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.
  • 解像度是像素數目(例如 1920 × 1080)。色彩深度是每個像素的位元數:1 位元有 2 種顏色,8 位元有 256 種,24 位元約有 1,670 萬種。
  • File size (bits) is width × height × colour depth. Example: 1024 × 768 × 24 bits is 2 359 296 bytes, which is 2.25 MB.
  • 檔案大小(位元)等於 寬 × 高 × 色彩深度。例子:1024 × 768 × 24 位元即 2 359 296 位元組,即 2.25 MB。
  • 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).
  • 聲音經取樣:ADC 每秒多次量度聲波的振幅。取樣率是每秒取樣次數(例如 44.1 kHz);位元深度(取樣大小)是每次取樣的位元數(例如 16 位元)。
  • Audio file size (bits) is sampling rate × sample size × channels × seconds. Example: 8000 Hz, 8-bit, mono, 10 s gives 640 000 bits, which is 80 000 bytes.
  • 聲音檔案大小(位元)等於 取樣率 × 位元深度 × 聲道數 × 秒數。例子:8000 Hz、8 位元、單聲道、10 秒,得 640 000 位元,即 80 000 位元組。
  • 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).
  • 無損壓縮縮小檔案而不會失去任何數據(例如 png、zip)。有損壓縮刪除人們難以察覺的數據,令檔案小得多(例如 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).
  • 文件:txt(純文字,無格式)、docx(Microsoft Word)、odt(開放文件格式,開放標準)、pdf(固定版面,在任何裝置上看起來都一樣)。

슬라이드

Sign up free to view the lesson slides

Step through every slide for this topic — plus flashcards and revision notes — with a free account.

연습 문제

무료 미리 보기 — 35개 중 8개 문제. 가입하면 전부 볼 수 있어요.
  1. 1.Which of the following is an example of analog data? 以下哪項是模擬數據的例子?

    Easy
    • AThe changing air pressure of a sound wave 聲波不斷改變的氣壓
    • BThe number of students in a class 班上的學生人數
    • CThe text in an email 電郵中的文字
    • DA student's ID number 學生編號
  2. 2.When a singer records a song with a microphone connected to a computer, which device converts the sound into binary? 歌手用連接電腦的咪高峰錄歌時,哪個裝置把聲音轉換成二進制?

    Easy
    • ADAC 數碼模擬轉換器
    • BADC 模擬數碼轉換器
    • CRouter 路由器
    • DSpeaker 揚聲器
  3. 3.Why do computers use binary to store data? (Select all that apply) 為何電腦以二進制儲存數據?(選出所有正確答案)

    Medium
    • AElectronic circuits have two stable states 電子電路有兩種穩定狀態
    • BTwo states are less affected by electrical noise 兩種狀態較少受電子雜訊影響
    • CBinary numbers are shorter than denary numbers 二進制數比十進制數短
    • DIt is easy to represent on/off in hardware 硬件容易表示開/關
  4. 4.How many different patterns can be represented with 10 bits? 10 個位元可以表示多少種不同組合?

    Easy
    • A20
    • B100
    • C512
    • D1024
  5. 5.Convert the binary number 00101101 to denary. 把二進制數 00101101 轉為十進制。

    Easy
  6. 6.What is the 8-bit binary representation of the denary number 99? 十進制數 99 的 8 位元二進制表示是甚麼?

    Medium
    • A01100011
    • B01100101
    • C01010011
    • D11000110
  7. 7.What is the hexadecimal value of the denary number 167? 十進制數 167 的十六進制值是甚麼?

    Medium
    • AA6
    • B7A
    • CA7
    • DB7
  8. 8.What is the 8-bit binary equivalent of the hexadecimal number 3F? 十六進制數 3F 的 8 位元二進制等值是甚麼?

    Medium
    • A00111111
    • B00110101
    • C11110011
    • D00111110

Unlock all 35 questions, flashcards & more

무료 계정을 만들어 이 주제의 모든 문제, 슬라이드, 플래시카드, 복습 노트를 확인하세요.

기출 문제

이 주제의 기출 문제 연습이 곧 나와요.
곧 출시