How exactly does binary code work? - José Américo N L F de Freitas
1,473,300 views ・ 2018-07-12
请双击下面的英文字幕来播放视频。
翻译人员: Robin W
校对人员: Carol Wang
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
指数从右向左,由 0 开始增长,
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
用一组特定的 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
就像单纯听到“DA”的声音,
你不能判断它的意思一样。
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
每个像素由 3 个二进制序列表示,
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
每秒的声音包含
多达 44000 个数字。
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
运行了数十亿次的结果。
New videos
Original video on YouTube.com
关于本网站
这个网站将向你介绍对学习英语有用的YouTube视频。你将看到来自世界各地的一流教师教授的英语课程。双击每个视频页面上显示的英文字幕,即可从那里播放视频。字幕会随着视频的播放而同步滚动。如果你有任何意见或要求,请使用此联系表与我们联系。