How exactly does binary code work? - José Américo N L F de Freitas

1,460,861 views ・ 2018-07-12

TED-Ed


請雙擊下方英文字幕播放視頻。

譯者: Lilian Chiu 審譯者: Helen Chang
00:06
Imagine trying to use words to describe every scene in a film,
0
6777
4638
想像一下,試圖用文字來描述 一部電影中的每一個場景、
00:11
every note in your favorite song,
1
11415
1903
你最愛的歌曲中的每一個音符,
00:13
or every street in your town.
2
13318
2717
或是你住的小鎮上的每一條街道。
00:16
Now imagine trying to do it using only the numbers 1 and 0.
3
16035
4824
現在,想像一下只用 1 和 0 這兩個數字來做這件事。
00:20
Every time you use the Internet to watch a movie,
4
20859
2895
每當你用網路看一部電影、
00:23
listen to music,
5
23754
1109
聽一首歌曲,
00:24
or check directions,
6
24863
1486
或查看方向時,
00:26
that’s exactly what your device is doing,
7
26349
2510
你的裝置就在做這件事,
00:28
using the language of binary code.
8
28859
2953
用二元編碼的語言來做這件事。
00:31
Computers use binary because it's a reliable way of storing data.
9
31812
4690
電腦會用二進位,是因為 用這種方式儲存資料很可靠。
00:36
For example, a computer's main memory is made of transistors
10
36502
4075
比如,電腦的主要記憶體 是由電晶體構成的,
00:40
that switch between either high or low voltage levels,
11
40577
3577
電晶體在高電壓和低電壓之間切換,
00:44
such as 5 volts and 0 volts.
12
44154
3490
比如 5 伏特和 0 伏特。
00:47
Voltages sometimes oscillate, but since there are only two options,
13
47644
4106
電壓有時會不穩, 但因為只有兩個選項,
00:51
a value of 1 volt would still be read as "low."
14
51750
4001
1 伏特仍然會被視為是「低電壓」。
00:55
That reading is done by the computer’s processor,
15
55751
2529
電腦的處理器讀取數值,
00:58
which uses the transistors’ states to control other computer devices
16
58280
4315
根據電晶體的狀態和軟體指令
來控制電腦的其他裝置。
01:02
according to software instructions.
17
62595
2196
01:04
The genius of this system is that a given binary sequence
18
64791
3341
這個系統的傑出之處
是給定的二進制序列 不被這台電腦自己預先訂定,
01:08
doesn't have a pre-determined meaning on its own.
19
68132
3388
01:11
Instead, each type of data is encoded in binary
20
71520
3685
而是另有二進制規則
編碼各種類型的數據。
01:15
according to a separate set of rules.
21
75205
2910
01:18
Let’s take numbers.
22
78115
1382
咱們用數字為例。
01:19
In normal decimal notation,
23
79497
1682
一般的十進制
01:21
each digit is multiplied by 10 raised to the value of its position,
24
81179
4853
從最右邊零的次方開始,
每個數字乘以 10, 向左直到其位置為止。
01:26
starting from zero on the right.
25
86032
2451
01:28
So 84 in decimal form is 4x10⁰ + 8x10¹.
26
88483
6557
所以十進位的 84 就是 4x10⁰ + 8x10¹。
01:35
Binary number notation works similarly,
27
95040
2715
二進位的表示方式也類似。
01:37
but with each position based on 2 raised to some power.
28
97755
3806
只是每個位置的數字 要乘以 2 的次方。
01:41
So 84 would be written as follows:
29
101561
4012
所以 84 會寫成這樣:
01:45
Meanwhile, letters are interpreted based on standard rules like UTF-8,
30
105573
4803
同時,字母則是根據像 UTF-8 這樣的標準規則來詮釋,
01:50
which assigns each character to a specific group of 8-digit binary strings.
31
110376
5107
UTF-8 會把每一個字母對應到 一組特定的 8 位數二進位字串,
01:55
In this case, 01010100 corresponds to the letter T.
32
115483
6906
在這個例子中,01010100 對應的是字母 T。
02:02
So, how can you know whether a given instance of this sequence
33
122389
3758
那麼,看到這個序列時,
02:06
is supposed to mean T or 84?
34
126147
2685
怎知它指的是 T 還是 84?
02:08
Well, you can’t from seeing the string alone
35
128832
3038
光看序列本身是看不出來的,
02:11
– just as you can’t tell what the sound "da" means from hearing it in isolation.
36
131870
4572
就像單獨聽到一個音「噠」, 無法判斷它是什麼意思。
02:16
You need context to tell whether you're hearing Russian, Spanish, or English.
37
136442
4837
需要有情境來告訴你,這個音是 俄文、西班牙文,或英文。
02:21
And you need similar context
38
141279
1391
你也需要類似的情境
02:22
to tell whether you’re looking at binary numbers or binary text.
39
142670
4115
來告訴你你現在看到的 是二進位的數字或二進位的文字。
02:26
Binary code is also used for far more complex types of data.
40
146785
4361
許多更複雜的資料也採用二元編碼。
02:31
Each frame of this video, for instance,
41
151146
2346
比如,這支影片的每一個畫格
02:33
is made of hundreds of thousands of pixels.
42
153492
2468
都是由數十萬個像素所組成。
02:35
In color images,
43
155960
1681
在彩色圖像中,
02:37
every pixel is represented by three binary sequences
44
157641
3454
每一個像素會用 三個二進位序列來表示,
02:41
that correspond to the primary colors.
45
161095
2606
它們對應到的就是三原色。
02:43
Each sequence encodes a number
46
163701
1786
每個序列是一個數字的編碼,
02:45
that determines the intensity of that particular color.
47
165487
3184
決定了那個顏色的強度。
02:48
Then, a video driver program transmits this information
48
168671
3929
接著,影片驅動程式 會將這些資訊傳送出去,
02:52
to the millions of liquid crystals in your screen
49
172600
2710
傳給螢幕上數百萬個液晶體,
02:55
to make all the different hues you see now.
50
175310
2778
來產生出各位現在看到的不同色彩。
02:58
The sound in this video is also stored in binary,
51
178088
3314
這支影片的聲音 也以二進位的方式儲存,
03:01
with the help of a technique called pulse code modulation.
52
181402
3404
用的是一種叫做 「脈衝編碼調變」的技術。
03:04
Continuous sound waves are digitized
53
184806
2384
將連續聲波數位化的方式
03:07
by taking "snapshots" of their amplitudes every few milliseconds.
54
187190
4392
每幾毫秒就「截取」一次 這些聲波的振幅。
03:11
These are recorded as numbers in the form of binary strings,
55
191582
3665
這些資訊會以二進位字串的 數字形式記錄下來,
03:15
with as many as 44,000 for every second of sound.
56
195247
3913
每秒的聲音有 44,000 個數字。
03:19
When they’re read by your computer’s audio software,
57
199160
2610
當電腦的影音軟體讀取這些資料時,
03:21
the numbers determine how quickly the coils in your speakers should vibrate
58
201770
4354
這些數字就決定 喇叭的音圈要震動得多快,
03:26
to create sounds of different frequencies.
59
206124
2841
來創造出不同頻率的聲音。
03:28
All of this requires billions and billions of bits.
60
208965
3695
這些都需要數以億計的位元。
03:32
But that amount can be reduced through clever compression formats.
61
212660
4003
但有了聰明的壓縮格式就能夠減量。
03:36
For example, if a picture has 30 adjacent pixels of green space,
62
216663
4508
比如,如果一張圖片 有 30 個相鄰的綠色像素,
03:41
they can be recorded as "30 green" instead of coding each pixel separately -
63
221171
4848
可以被記錄成「30 個綠色像素」, 而不是把每個像素分開記錄——
03:46
a process known as run-length encoding.
64
226019
3175
這個過程就是熟知的游程編碼。
03:49
These compressed formats are themselves written in binary code.
65
229194
4900
這些壓縮格式本身 也是用二進位寫成的。
03:54
So is binary the end-all-be-all of computing?
66
234094
3070
二進位制是最棒的計算編碼嗎?
03:57
Not necessarily.
67
237164
1385
不見得。
03:58
There’s been research into ternary computers,
68
238549
2418
已經有人在研究三位元電腦,
04:00
with circuits in three possible states,
69
240967
2465
那電路會有三種可能的狀態;
04:03
and even quantum computers,
70
243432
1820
甚至還有四進位的電腦,
04:05
whose circuits can be in multiple states simultaneously.
71
245252
3664
它的電路可以同時具有多個狀態。
04:08
But so far, none of these has provided
72
248916
2423
但截至目前為止 在資料的儲存和傳輸上,
04:11
as much physical stability for data storage and transmission.
73
251339
3296
這些發明尚未能 提供夠高的物理穩定性。
04:14
So for now, everything you see,
74
254635
2444
所以到目前為止
你在螢幕上看見、
04:17
hear,
75
257079
769
04:17
and read through your screen
76
257848
1616
聽見、讀到的一切,
04:19
comes to you as the result of a simple "true" or "false" choice,
77
259464
3633
都是以數十億個簡單 「是非題」的結果傳給你的。
04:23
made billions of times over.
78
263097
2274
關於本網站

本網站將向您介紹對學習英語有用的 YouTube 視頻。 您將看到來自世界各地的一流教師教授的英語課程。 雙擊每個視頻頁面上顯示的英文字幕,從那裡播放視頻。 字幕與視頻播放同步滾動。 如果您有任何意見或要求,請使用此聯繫表與我們聯繫。

https://forms.gle/WvT1wiN1qDtmnspy7