Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,079 --> 00:00:03,060
hello and welcome back to CS 420 a
2
00:00:03,060 --> 00:00:05,730
course on game hacking in this lecture
3
00:00:05,730 --> 00:00:07,200
we'll be covering base systems
4
00:00:07,200 --> 00:00:09,540
base systems are just ways to express
5
00:00:09,540 --> 00:00:11,820
numbers the numbers on this slide are
6
00:00:11,820 --> 00:00:13,920
all the same number written in different
7
00:00:13,920 --> 00:00:17,130
base systems binary decimal and hex now
8
00:00:17,130 --> 00:00:18,960
we dabbled in binary a little bit last
9
00:00:18,960 --> 00:00:20,880
lecture but now we're gonna develop a
10
00:00:20,880 --> 00:00:23,570
true understanding of how binary and hex
11
00:00:23,570 --> 00:00:26,400
now I know what you're thinking I came
12
00:00:26,400 --> 00:00:27,869
here to learn how to hack and now you're
13
00:00:27,869 --> 00:00:29,400
gonna lecture me on numbers is this some
14
00:00:29,400 --> 00:00:32,159
sort of sick joke the answer is yes it
15
00:00:32,159 --> 00:00:34,170
is a sick joke but don't blame me I'm
16
00:00:34,170 --> 00:00:36,480
just the messenger this is a small but
17
00:00:36,480 --> 00:00:38,460
necessary detour before we get back into
18
00:00:38,460 --> 00:00:40,710
hacking this happens a lot when you want
19
00:00:40,710 --> 00:00:42,809
to learn cool subjects if you want to
20
00:00:42,809 --> 00:00:44,370
learn machine learning you need to learn
21
00:00:44,370 --> 00:00:46,289
a little bit of statistics if you want
22
00:00:46,289 --> 00:00:47,610
to learn physics you need to learn a
23
00:00:47,610 --> 00:00:49,770
little bit of calculus we actually have
24
00:00:49,770 --> 00:00:51,570
it quite easy in comparison we're just
25
00:00:51,570 --> 00:00:53,730
learning how to count again before we
26
00:00:53,730 --> 00:00:55,140
get started let me give you some
27
00:00:55,140 --> 00:00:58,590
inspiration this is an excerpt from a
28
00:00:58,590 --> 00:01:00,600
book about dead languages not
29
00:01:00,600 --> 00:01:02,789
programming languages but actual spoken
30
00:01:02,789 --> 00:01:05,729
languages it reads the pop and language
31
00:01:05,729 --> 00:01:07,350
boogie up has two different counting
32
00:01:07,350 --> 00:01:09,810
systems one base for and another base
33
00:01:09,810 --> 00:01:12,210
three according to boogie up custom
34
00:01:12,210 --> 00:01:14,070
which system use depends on which
35
00:01:14,070 --> 00:01:16,350
objects you are counting so ancient
36
00:01:16,350 --> 00:01:18,420
Papua New Guineans actually new to base
37
00:01:18,420 --> 00:01:20,670
systems and have peasants living on a
38
00:01:20,670 --> 00:01:22,680
remote island several thousand years ago
39
00:01:22,680 --> 00:01:25,200
can learn multiple base systems then an
40
00:01:25,200 --> 00:01:27,900
aspiring 21st century hacker with access
41
00:01:27,900 --> 00:01:29,520
to the world's knowledge and Internet
42
00:01:29,520 --> 00:01:32,329
has no excuse
43
00:01:32,369 --> 00:01:33,450
let's actually take a look at this
44
00:01:33,450 --> 00:01:35,070
language there's a few lessons it can
45
00:01:35,070 --> 00:01:36,840
teach us that we can apply to binary and
46
00:01:36,840 --> 00:01:39,719
hex so on the Left we have objects that
47
00:01:39,719 --> 00:01:41,819
we count by fours things like coconuts
48
00:01:41,819 --> 00:01:45,090
lizards bows and arrows and on the right
49
00:01:45,090 --> 00:01:46,579
we have things that we count by threes
50
00:01:46,579 --> 00:01:49,740
things like beetle nuts bananas and
51
00:01:49,740 --> 00:01:52,079
shields now I want to point something
52
00:01:52,079 --> 00:01:54,810
very interesting out on the Left we have
53
00:01:54,810 --> 00:01:56,850
small yams and on the right we have big
54
00:01:56,850 --> 00:01:57,420
yams
55
00:01:57,420 --> 00:01:59,670
that means if I wanted to sell you two
56
00:01:59,670 --> 00:02:02,130
groups of yams you better be careful
57
00:02:02,130 --> 00:02:04,170
because if I'm talking about small yams
58
00:02:04,170 --> 00:02:06,090
then there's eight of them but if I'm
59
00:02:06,090 --> 00:02:07,739
talking about big yams and that means
60
00:02:07,739 --> 00:02:10,049
there are six of them the important
61
00:02:10,049 --> 00:02:11,700
lesson here is that numbers can mean
62
00:02:11,700 --> 00:02:13,200
different things depending on the
63
00:02:13,200 --> 00:02:16,170
context depending on the base system and
64
00:02:16,170 --> 00:02:18,540
just a side note if you read up on this
65
00:02:18,540 --> 00:02:20,040
language you'll find that I simplified
66
00:02:20,040 --> 00:02:21,720
things a little bit it's quite
67
00:02:21,720 --> 00:02:23,579
fascinating but really beyond the scope
68
00:02:23,579 --> 00:02:25,079
of this lecture to go into more detail
69
00:02:25,079 --> 00:02:26,430
you can look it up on your own if you
70
00:02:26,430 --> 00:02:27,890
want
71
00:02:27,890 --> 00:02:30,110
but let's take this lesson and apply it
72
00:02:30,110 --> 00:02:33,290
to what we what we know our systems if
73
00:02:33,290 --> 00:02:35,810
we have the number 10 we know what that
74
00:02:35,810 --> 00:02:37,850
is and we can visualize it is the number
75
00:02:37,850 --> 00:02:40,010
of fingers on our hands now if we take
76
00:02:40,010 --> 00:02:42,170
that same number written down and look
77
00:02:42,170 --> 00:02:44,960
at it in the context of hexadecimal well
78
00:02:44,960 --> 00:02:48,290
it actually means 16 and binary it
79
00:02:48,290 --> 00:02:51,170
actually means 2 it's similar to the
80
00:02:51,170 --> 00:02:52,760
problem I mentioned before with the yams
81
00:02:52,760 --> 00:02:54,590
we need to know if it's big games or
82
00:02:54,590 --> 00:02:55,940
little yams we need to know if it's
83
00:02:55,940 --> 00:02:58,730
binary or hex
84
00:02:58,730 --> 00:03:00,980
to avoid confusion sometimes people put
85
00:03:00,980 --> 00:03:03,860
a 0x before a hex number and zero B
86
00:03:03,860 --> 00:03:06,260
before binary numbers people don't
87
00:03:06,260 --> 00:03:08,120
always use these prefixes so it can get
88
00:03:08,120 --> 00:03:09,650
a little confusing but just know that
89
00:03:09,650 --> 00:03:11,780
when you see these prefixes you can no
90
00:03:11,780 --> 00:03:13,550
longer trust your eyes and brain
91
00:03:13,550 --> 00:03:17,349
the numbers are in those contexts now
92
00:03:17,349 --> 00:03:19,810
before we go on let's take a step back
93
00:03:19,810 --> 00:03:22,030
and ask ourselves why we even need to
94
00:03:22,030 --> 00:03:24,579
learn this stuff it goes without saying
95
00:03:24,579 --> 00:03:27,519
that humans use base 10 a common
96
00:03:27,519 --> 00:03:29,530
question people have is is there
97
00:03:29,530 --> 00:03:32,230
anything special about base 10 and the
98
00:03:32,230 --> 00:03:34,120
answer is not really we just chose it
99
00:03:34,120 --> 00:03:35,500
because it works well with a number of
100
00:03:35,500 --> 00:03:38,319
fingers we have a lot of mathematicians
101
00:03:38,319 --> 00:03:41,049
actually think base 10 was a mistake if
102
00:03:41,049 --> 00:03:43,180
you buy Donuts in the USA they come in
103
00:03:43,180 --> 00:03:44,919
twelve and there's a reason for that
104
00:03:44,919 --> 00:03:46,959
twelve is easier to split with your
105
00:03:46,959 --> 00:03:49,269
friends if there's two of you you both
106
00:03:49,269 --> 00:03:50,919
get six if there's three of you
107
00:03:50,919 --> 00:03:52,840
y'all get four that there's four of you
108
00:03:52,840 --> 00:03:55,000
you all get three and if there's six of
109
00:03:55,000 --> 00:03:57,280
you everyone gets two it divides up
110
00:03:57,280 --> 00:03:59,620
really well and math that's known as a
111
00:03:59,620 --> 00:04:02,349
highly composite number now let's take a
112
00:04:02,349 --> 00:04:03,849
look at computers they store information
113
00:04:03,849 --> 00:04:07,540
and either an on or off state and this
114
00:04:07,540 --> 00:04:09,730
gives rise to a natural base to system
115
00:04:09,730 --> 00:04:12,909
zero for off one for on that's two
116
00:04:12,909 --> 00:04:16,269
options base two now this sucks for us
117
00:04:16,269 --> 00:04:18,009
as humans because we never learned base
118
00:04:18,009 --> 00:04:21,310
two we invented machines that do math in
119
00:04:21,310 --> 00:04:22,840
a system that the majority of us don't
120
00:04:22,840 --> 00:04:26,080
understand so now we need to learn it if
121
00:04:26,080 --> 00:04:27,759
you've been super observant you may be
122
00:04:27,759 --> 00:04:29,860
asking hey what about hex where does
123
00:04:29,860 --> 00:04:30,639
that come from
124
00:04:30,639 --> 00:04:33,460
hex is base 16 how does that fit into
125
00:04:33,460 --> 00:04:36,520
this I hinted at this earlier with my
126
00:04:36,520 --> 00:04:38,500
rant about the doughnuts different base
127
00:04:38,500 --> 00:04:40,530
systems are good for different problems
128
00:04:40,530 --> 00:04:42,639
base two is good because it can
129
00:04:42,639 --> 00:04:44,520
represent things that are on and off
130
00:04:44,520 --> 00:04:46,780
base 10 is good because that's how many
131
00:04:46,780 --> 00:04:48,639
fingers we have and it's convenient for
132
00:04:48,639 --> 00:04:51,130
humans base 12 is good for dividing
133
00:04:51,130 --> 00:04:53,199
things up and you actually know another
134
00:04:53,199 --> 00:04:54,610
base you just don't know that you know
135
00:04:54,610 --> 00:04:57,880
it that's base one base one is tally
136
00:04:57,880 --> 00:05:00,219
marks tally marks are good for counting
137
00:05:00,219 --> 00:05:02,560
things as they happen by counting votes
138
00:05:02,560 --> 00:05:04,330
in a classroom we're keeping track of
139
00:05:04,330 --> 00:05:06,099
how many times different teams have won
140
00:05:06,099 --> 00:05:08,349
in a competition this is useful because
141
00:05:08,349 --> 00:05:09,909
he never have to erase you can just keep
142
00:05:09,909 --> 00:05:11,900
adding more marks
143
00:05:11,900 --> 00:05:14,210
base-16 also solves a problem but it's a
144
00:05:14,210 --> 00:05:16,910
subtle problem in a bit more nuanced so
145
00:05:16,910 --> 00:05:18,199
we need to learn a few more things
146
00:05:18,199 --> 00:05:20,830
before we can get into it
147
00:05:20,830 --> 00:05:23,080
before we try to learn binary hex we
148
00:05:23,080 --> 00:05:25,150
need to unlearn decimal this is the
149
00:05:25,150 --> 00:05:26,650
hardest part for people because you've
150
00:05:26,650 --> 00:05:28,240
been staring at decimal numbers your
151
00:05:28,240 --> 00:05:30,940
entire life let's play coast attention
152
00:05:30,940 --> 00:05:33,759
to how we count numbers once we get to
153
00:05:33,759 --> 00:05:36,930
ten we recycle digits the number ten
154
00:05:36,930 --> 00:05:40,000
reuses the digits one and zero the
155
00:05:40,000 --> 00:05:42,970
number eleven reuses one and one again
156
00:05:42,970 --> 00:05:46,780
so let me ask you why not invent a new
157
00:05:46,780 --> 00:05:49,850
symbol instead of just recycling
158
00:05:49,850 --> 00:05:52,340
right what if we just kept going in this
159
00:05:52,340 --> 00:05:56,560
example a is 10 and B is 11 and so on
160
00:05:56,560 --> 00:05:59,180
well obviously we can't come up with a
161
00:05:59,180 --> 00:06:00,830
new symbol for every number because
162
00:06:00,830 --> 00:06:03,170
there are infinite numbers and it's just
163
00:06:03,170 --> 00:06:05,390
not sustainable at some point we need to
164
00:06:05,390 --> 00:06:07,880
reuse symbols and base systems tell us
165
00:06:07,880 --> 00:06:10,250
how many digits we can use before we
166
00:06:10,250 --> 00:06:13,240
need to start recycling
167
00:06:13,319 --> 00:06:15,210
here's a system with way too many
168
00:06:15,210 --> 00:06:17,699
symbols this is the Babylonian numeral
169
00:06:17,699 --> 00:06:20,789
system and it's base 60 maybe this is
170
00:06:20,789 --> 00:06:22,740
why the Babylonian Empire fell apart I
171
00:06:22,740 --> 00:06:24,539
can just imagine it general trying to
172
00:06:24,539 --> 00:06:26,399
scribble down a note asking for the king
173
00:06:26,399 --> 00:06:29,490
to send a hundred horses was a triangle
174
00:06:29,490 --> 00:06:31,680
triangle arrow arrow or arrow arrow
175
00:06:31,680 --> 00:06:34,080
triangle triangle it's like punching in
176
00:06:34,080 --> 00:06:35,460
a Konami code every time you want to ask
177
00:06:35,460 --> 00:06:37,619
for simple favor but it does have one
178
00:06:37,619 --> 00:06:39,869
thing going for its base 60 it's it
179
00:06:39,869 --> 00:06:43,110
divides up very well similar to 12 but
180
00:06:43,110 --> 00:06:44,639
it's still way too many symbols to
181
00:06:44,639 --> 00:06:47,789
memorize but look what happens when we
182
00:06:47,789 --> 00:06:50,520
have too few digits the Babylonians had
183
00:06:50,520 --> 00:06:52,319
too many and it was overwhelming with
184
00:06:52,319 --> 00:06:54,569
binary we have too few and it's even
185
00:06:54,569 --> 00:06:56,819
more unreadable it turns out that
186
00:06:56,819 --> 00:06:58,229
there's a range of digits that work
187
00:06:58,229 --> 00:07:00,119
really well for humans probably between
188
00:07:00,119 --> 00:07:02,550
7 and 20 this is my own personal
189
00:07:02,550 --> 00:07:04,740
estimate a linguist would be more suited
190
00:07:04,740 --> 00:07:06,659
to come up with the exact range but you
191
00:07:06,659 --> 00:07:08,889
get the general idea
192
00:07:08,889 --> 00:07:11,319
let's do another thought experiment what
193
00:07:11,319 --> 00:07:13,590
would happen if we invented a new digit
194
00:07:13,590 --> 00:07:16,449
let's add a new digit between nine and
195
00:07:16,449 --> 00:07:19,870
ten using the letter A well the numbers
196
00:07:19,870 --> 00:07:23,349
gets shifted now a represents 10 which
197
00:07:23,349 --> 00:07:26,110
means that 10 actually represents 11 and
198
00:07:26,110 --> 00:07:28,569
if that's confusing just count out the
199
00:07:28,569 --> 00:07:33,639
numbers on the bottom row 0 1 2 3 4 5 6
200
00:07:33,639 --> 00:07:38,460
7 8 9 10 11
201
00:07:38,610 --> 00:07:41,010
the further we go the worse the shifting
202
00:07:41,010 --> 00:07:43,710
gets what we thought it was ten actually
203
00:07:43,710 --> 00:07:46,140
represents eleven and what we used to
204
00:07:46,140 --> 00:07:48,240
think of as twenty actually represents
205
00:07:48,240 --> 00:07:50,790
twenty-two we can no longer trust our
206
00:07:50,790 --> 00:07:53,490
eyes here's another brain bender
207
00:07:53,490 --> 00:07:56,460
what if we removed the number nine well
208
00:07:56,460 --> 00:07:58,560
ten would take a spot so we used to
209
00:07:58,560 --> 00:08:00,630
think of as ten would actually now
210
00:08:00,630 --> 00:08:03,330
represent nine what we used to think of
211
00:08:03,330 --> 00:08:04,980
as twenty would actually represent
212
00:08:04,980 --> 00:08:08,370
eighteen the numbers are just shifted
213
00:08:08,370 --> 00:08:10,140
again but this time in the opposite
214
00:08:10,140 --> 00:08:12,870
direction let's apply this to the
215
00:08:12,870 --> 00:08:15,360
systems that we need to learn these are
216
00:08:15,360 --> 00:08:17,490
the numbers for each base system decimal
217
00:08:17,490 --> 00:08:19,770
is obviously zero to nine for a total of
218
00:08:19,770 --> 00:08:23,580
ten choices and space ten binary is zero
219
00:08:23,580 --> 00:08:27,120
and one totaling two choices but hex
220
00:08:27,120 --> 00:08:29,610
needs sixteen symbols and that's six
221
00:08:29,610 --> 00:08:31,110
more than we used to because we're going
222
00:08:31,110 --> 00:08:34,740
from ten to sixteen so we we need six
223
00:08:34,740 --> 00:08:37,350
new single-digit characters so we just
224
00:08:37,350 --> 00:08:39,470
steal them from the alphabet
225
00:08:39,470 --> 00:08:41,630
if we count these out similar to the
226
00:08:41,630 --> 00:08:43,070
previous thought experiments the
227
00:08:43,070 --> 00:08:46,790
shifting it's really bad a is 10 B is 11
228
00:08:46,790 --> 00:08:50,900
C is 12 and so on what we think of as 10
229
00:08:50,900 --> 00:08:54,620
to us is actually 16 what we think of as
230
00:08:54,620 --> 00:08:58,330
20 is actually 32
231
00:08:59,110 --> 00:09:01,030
now let's take a look at the same number
232
00:09:01,030 --> 00:09:03,490
represented in this in all three bae
233
00:09:03,490 --> 00:09:04,930
systems so all three of these numbers
234
00:09:04,930 --> 00:09:06,100
are the same
235
00:09:06,100 --> 00:09:08,500
notice how ugly the number is
236
00:09:08,500 --> 00:09:12,340
pre-decimal and with hex and binary
237
00:09:12,340 --> 00:09:14,980
there seems to be some sort of structure
238
00:09:14,980 --> 00:09:19,120
right it's a repeated letter well I want
239
00:09:19,120 --> 00:09:21,310
to point something special out look what
240
00:09:21,310 --> 00:09:23,440
happens when we space out the binary in
241
00:09:23,440 --> 00:09:26,440
hex for every four binary numbers
242
00:09:26,440 --> 00:09:29,140
there's one hex number
243
00:09:29,140 --> 00:09:32,680
if we change the hex number to be FA FFF
244
00:09:32,680 --> 00:09:34,959
and so on look what happens to the
245
00:09:34,959 --> 00:09:39,220
binary the group that used to be 1 1 1 1
246
00:09:39,220 --> 00:09:43,360
is actually now 1 0 1 0 there's a strong
247
00:09:43,360 --> 00:09:46,959
correlation between the hex number and
248
00:09:46,959 --> 00:09:51,070
the corresponding 4 binary numbers so
249
00:09:51,070 --> 00:09:52,660
this is what I was talking about earlier
250
00:09:52,660 --> 00:09:54,510
when I said that hex solves a problem
251
00:09:54,510 --> 00:09:57,970
humans can't read binary very well it
252
00:09:57,970 --> 00:09:59,860
doesn't convert to decimal very well
253
00:09:59,860 --> 00:10:03,579
either however it is easy to convert
254
00:10:03,579 --> 00:10:06,339
from binary to hex if you gave me ten
255
00:10:06,339 --> 00:10:08,350
thousand digits of binary I could
256
00:10:08,350 --> 00:10:11,019
convert them to hex by hand by simply
257
00:10:11,019 --> 00:10:13,269
breaking them up into chunks of four and
258
00:10:13,269 --> 00:10:15,370
converting those four-digit chunks into
259
00:10:15,370 --> 00:10:18,190
hex if you ask someone to convert the
260
00:10:18,190 --> 00:10:20,610
same 10,000 digits of binary to decimal
261
00:10:20,610 --> 00:10:22,720
no human could do it without a
262
00:10:22,720 --> 00:10:24,930
calculator
263
00:10:25,350 --> 00:10:27,660
so now let's actually learn how to count
264
00:10:27,660 --> 00:10:31,290
in binary I'll explain the same concept
265
00:10:31,290 --> 00:10:33,330
in a few different ways so if one
266
00:10:33,330 --> 00:10:34,770
explanation doesn't make sense to you
267
00:10:34,770 --> 00:10:36,360
don't worry
268
00:10:36,360 --> 00:10:38,879
first let's look at an idea that we're
269
00:10:38,879 --> 00:10:42,360
familiar with in decimal if we have the
270
00:10:42,360 --> 00:10:45,149
number nine nine nine nine nine and we
271
00:10:45,149 --> 00:10:49,000
add one something happens
272
00:10:49,000 --> 00:10:51,069
there's a cascade effect where all the
273
00:10:51,069 --> 00:10:53,949
nines turn into zeros and we add a one
274
00:10:53,949 --> 00:10:56,460
to the very end
275
00:10:56,460 --> 00:10:59,670
well in binary it's the same idea what
276
00:10:59,670 --> 00:11:01,470
would happen if we added one to this
277
00:11:01,470 --> 00:11:03,570
number
278
00:11:03,570 --> 00:11:05,970
well there's a cascade effect where all
279
00:11:05,970 --> 00:11:08,430
the preceding ones turn into zeros and
280
00:11:08,430 --> 00:11:11,310
we put a one at the end but remember
281
00:11:11,310 --> 00:11:13,290
that in decimal we run out of digits at
282
00:11:13,290 --> 00:11:15,779
nine and in binary we run out of digits
283
00:11:15,779 --> 00:11:18,990
at one so this cascading effect happens
284
00:11:18,990 --> 00:11:22,230
a lot more frequently let's take a look
285
00:11:22,230 --> 00:11:24,990
at binary counting in action I'll just
286
00:11:24,990 --> 00:11:26,850
let the animation play out and you can
287
00:11:26,850 --> 00:11:28,560
watch and try to figure out what's going
288
00:11:28,560 --> 00:11:31,100
on in your own
289
00:11:36,400 --> 00:11:38,460
you
290
00:11:45,310 --> 00:11:47,110
there isn't too much I can really add
291
00:11:47,110 --> 00:11:48,730
here unfortunately it's one of those
292
00:11:48,730 --> 00:11:50,400
things that either clicks or it doesn't
293
00:11:50,400 --> 00:11:53,230
if not we'll go over a few ways to think
294
00:11:53,230 --> 00:11:55,330
about this and hopefully one of those
295
00:11:55,330 --> 00:11:57,040
other methods will click if this one
296
00:11:57,040 --> 00:12:00,660
isn't doing it for you
297
00:12:02,140 --> 00:12:04,690
so let's take a look at another idea
298
00:12:04,690 --> 00:12:07,000
that we understand in decimal we know
299
00:12:07,000 --> 00:12:08,800
that a hundred is ten times more
300
00:12:08,800 --> 00:12:13,060
powerful than ten and we know that 1,000
301
00:12:13,060 --> 00:12:14,740
is ten times more powerful than a
302
00:12:14,740 --> 00:12:17,680
hundred so one way to think about this
303
00:12:17,680 --> 00:12:19,720
is that a one in the hundreds place is
304
00:12:19,720 --> 00:12:21,579
ten times more powerful than a one in
305
00:12:21,579 --> 00:12:24,959
the tens place and so on
306
00:12:25,880 --> 00:12:28,779
let's look at that same idea in binary
307
00:12:28,779 --> 00:12:32,029
so that the left column here is the
308
00:12:32,029 --> 00:12:33,740
binary number in the right column is a
309
00:12:33,740 --> 00:12:36,949
corresponding decimal number now the top
310
00:12:36,949 --> 00:12:40,190
left number here which is one we can
311
00:12:40,190 --> 00:12:42,949
ignore the leading zeros that it's the
312
00:12:42,949 --> 00:12:44,360
same thing as putting like a zero before
313
00:12:44,360 --> 00:12:46,040
a decimal number it doesn't matter but a
314
00:12:46,040 --> 00:12:47,600
lot of people do it in binary to make it
315
00:12:47,600 --> 00:12:49,720
look cleaner
316
00:12:49,720 --> 00:12:51,820
okay so now let's look at the next
317
00:12:51,820 --> 00:12:54,490
number we know the top one is one well
318
00:12:54,490 --> 00:12:58,240
the next one is two and you can think of
319
00:12:58,240 --> 00:13:01,930
this as a 1 and the second position
320
00:13:01,930 --> 00:13:05,080
there is worth twice as much as a 1 in
321
00:13:05,080 --> 00:13:07,510
the first position right similar hap to
322
00:13:07,510 --> 00:13:11,920
how in decimal a hundred is ten times
323
00:13:11,920 --> 00:13:14,890
more powerful than 10 in this case we're
324
00:13:14,890 --> 00:13:16,540
doing twice as powerful because we're
325
00:13:16,540 --> 00:13:18,910
base 2 so we have a 1 in the first
326
00:13:18,910 --> 00:13:22,720
position over here and a 1 in the second
327
00:13:22,720 --> 00:13:24,820
position is twice as powerful so it goes
328
00:13:24,820 --> 00:13:27,790
from 1 to 2 and now if we move that one
329
00:13:27,790 --> 00:13:30,300
over to the third position here it's
330
00:13:30,300 --> 00:13:32,710
twice as powerful as the previous number
331
00:13:32,710 --> 00:13:36,570
so this one is actually 4
332
00:13:38,480 --> 00:13:40,550
so a thought experiment what do you
333
00:13:40,550 --> 00:13:44,230
think the number on the right represents
334
00:13:44,230 --> 00:13:46,790
well it's actually pretty easy to do you
335
00:13:46,790 --> 00:13:49,010
just add up how powerful each digit is
336
00:13:49,010 --> 00:13:52,220
we establish that one zero is worth two
337
00:13:52,220 --> 00:13:55,550
and that one zero zero is worth four so
338
00:13:55,550 --> 00:13:58,100
you can actually just add two and four
339
00:13:58,100 --> 00:14:01,760
and this number is six
340
00:14:01,760 --> 00:14:03,769
let's take a look at the same idea in
341
00:14:03,769 --> 00:14:06,740
chart form so the first row we have 1 1
342
00:14:06,740 --> 00:14:10,880
0 1 1 and we spread out those digits
343
00:14:10,880 --> 00:14:14,050
over the column so we have 1 1 0 1 1
344
00:14:14,050 --> 00:14:17,720
now we established that a 1 in the first
345
00:14:17,720 --> 00:14:20,089
position is only worth 1 but a 1 in the
346
00:14:20,089 --> 00:14:22,970
second position is worth 2 and so on so
347
00:14:22,970 --> 00:14:25,010
if you look at the top top arrows here
348
00:14:25,010 --> 00:14:30,130
or top column sorry we have 1 2 4 8 16
349
00:14:30,130 --> 00:14:33,350
because each place is worth twice the
350
00:14:33,350 --> 00:14:38,839
previous so what we can do is if the one
351
00:14:38,839 --> 00:14:42,290
is set we add what it's worth so 1 in
352
00:14:42,290 --> 00:14:44,269
the first position is worth 1 so we have
353
00:14:44,269 --> 00:14:47,930
1 plus we have a 1 in the second
354
00:14:47,930 --> 00:14:48,410
position
355
00:14:48,410 --> 00:14:51,529
that's where 2 so 1 plus 2 and this
356
00:14:51,529 --> 00:14:53,089
one's not said so we don't do anything
357
00:14:53,089 --> 00:14:55,430
there's a 0 here we ignore it now
358
00:14:55,430 --> 00:14:58,730
there's an 8 set here so 1 plus 2 Plus 8
359
00:14:58,730 --> 00:15:01,790
and there's a 1 in the 16 column so now
360
00:15:01,790 --> 00:15:03,889
we have 1 plus 2 plus a plus 16 that
361
00:15:03,889 --> 00:15:06,949
gives us 27 in decimal so now you know
362
00:15:06,949 --> 00:15:08,540
how to piece this together just by
363
00:15:08,540 --> 00:15:10,120
looking at it
364
00:15:10,120 --> 00:15:12,790
now let's look at the second row this
365
00:15:12,790 --> 00:15:14,110
one's a little easier there's a lot of
366
00:15:14,110 --> 00:15:17,980
zeros the one bit is set so we have one
367
00:15:17,980 --> 00:15:21,040
plus two isn't set it's a zero so we
368
00:15:21,040 --> 00:15:24,339
skip that one and the four bit is set so
369
00:15:24,339 --> 00:15:28,629
one plus four for a total of five and if
370
00:15:28,629 --> 00:15:30,129
you want to do this last one I'll leave
371
00:15:30,129 --> 00:15:32,920
that as an exercise to the reader but it
372
00:15:32,920 --> 00:15:34,839
should work exactly the same way very
373
00:15:34,839 --> 00:15:37,390
straightforward
374
00:15:37,390 --> 00:15:40,209
and if we wanted to keep going we would
375
00:15:40,209 --> 00:15:43,269
actually add a rose for 64 sorry 32 then
376
00:15:43,269 --> 00:15:47,050
64 then 128 I hope that makes some sense
377
00:15:47,050 --> 00:15:49,209
to you I'm not gonna I'm not going to go
378
00:15:49,209 --> 00:15:50,560
through examples here but the idea is
379
00:15:50,560 --> 00:15:52,240
that each position you multiply by two
380
00:15:52,240 --> 00:15:55,390
so the more digits you have the more
381
00:15:55,390 --> 00:15:58,750
powerful the leftmost digits are
382
00:15:58,750 --> 00:16:00,910
this is a neat trick it's not super
383
00:16:00,910 --> 00:16:02,139
useful but I thought I'd teach it
384
00:16:02,139 --> 00:16:04,269
anyways you can actually count to 31 on
385
00:16:04,269 --> 00:16:06,250
one hand by treating your fingers as
386
00:16:06,250 --> 00:16:10,060
either 0 or 1 if you use both hands you
387
00:16:10,060 --> 00:16:11,769
can actually count up to a thousand and
388
00:16:11,769 --> 00:16:14,379
23 there's just a little awkward because
389
00:16:14,379 --> 00:16:15,939
you can end up accidentally flipping
390
00:16:15,939 --> 00:16:19,779
people off when you count to 4 but still
391
00:16:19,779 --> 00:16:22,420
pretty neat just be sure not to insult
392
00:16:22,420 --> 00:16:24,550
your teachers if you show them this
393
00:16:24,550 --> 00:16:26,819
trick
394
00:16:27,110 --> 00:16:28,730
and if it doesn't make much sense you
395
00:16:28,730 --> 00:16:31,580
can just use a calculator let's actually
396
00:16:31,580 --> 00:16:34,780
jump into what that would look like
397
00:16:35,610 --> 00:16:38,270
so here we have the windows calculator
398
00:16:38,270 --> 00:16:40,800
what we can do is go into the options
399
00:16:40,800 --> 00:16:41,490
here
400
00:16:41,490 --> 00:16:44,150
switch to programmer mode
401
00:16:44,150 --> 00:16:47,000
and this gives us access to conversions
402
00:16:47,000 --> 00:16:49,460
so if we type in a number in decimal say
403
00:16:49,460 --> 00:16:52,400
255 we can click on the hex version here
404
00:16:52,400 --> 00:16:55,460
and we could see that it's FF and hex we
405
00:16:55,460 --> 00:16:57,350
can click on binary here to see that
406
00:16:57,350 --> 00:17:01,850
it's 1 1 1 1 whatever in binary and we
407
00:17:01,850 --> 00:17:03,590
could do this for any numbered type in
408
00:17:03,590 --> 00:17:05,210
some giant number we could see what it
409
00:17:05,210 --> 00:17:07,849
is in binary we can also do it the other
410
00:17:07,849 --> 00:17:09,680
way if we know what the number is in hex
411
00:17:09,680 --> 00:17:12,380
we can click on hex clear this and then
412
00:17:12,380 --> 00:17:15,020
just start typing the hex number and we
413
00:17:15,020 --> 00:17:17,839
can see what it is in binary so this is
414
00:17:17,839 --> 00:17:19,490
wonderful I taught you everything else
415
00:17:19,490 --> 00:17:21,230
for no reason because turns out that
416
00:17:21,230 --> 00:17:23,359
you'll probably just end up using this
417
00:17:23,359 --> 00:17:26,170
for most of everything you need to do
418
00:17:26,170 --> 00:17:28,640
there's no reason to convert anything in
419
00:17:28,640 --> 00:17:30,170
your head these days however it's still
420
00:17:30,170 --> 00:17:32,020
very important to be able to eyeball
421
00:17:32,020 --> 00:17:34,670
small binary numbers and convert small
422
00:17:34,670 --> 00:17:36,800
numbers in your head but if you're
423
00:17:36,800 --> 00:17:38,270
running into something like this just
424
00:17:38,270 --> 00:17:40,910
use a calculator save yourself the time
425
00:17:40,910 --> 00:17:45,110
if you're on Linux or Mac they also have
426
00:17:45,110 --> 00:17:46,780
a programmer mode on their calculator
427
00:17:46,780 --> 00:17:50,660
I'm not gonna go over how to open that
428
00:17:50,660 --> 00:17:52,850
programmer mode on those but it's it
429
00:17:52,850 --> 00:17:54,710
works almost exactly the same way so
430
00:17:54,710 --> 00:17:56,620
there's no reason to be redundant here
431
00:17:56,620 --> 00:17:59,120
the best way to solidify what you've
432
00:17:59,120 --> 00:18:00,830
learned is to actually get out there and
433
00:18:00,830 --> 00:18:03,020
do some hands-on activities so I'm going
434
00:18:03,020 --> 00:18:04,550
to point a few out there's some video
435
00:18:04,550 --> 00:18:08,050
games that I'd like you to play
436
00:18:08,730 --> 00:18:10,290
so the first game I wanted to point out
437
00:18:10,290 --> 00:18:12,120
is this flippy bit and the attack of the
438
00:18:12,120 --> 00:18:14,850
hexadecimals from base 16 it's a little
439
00:18:14,850 --> 00:18:16,799
bit of a cheesy game but it's free and
440
00:18:16,799 --> 00:18:18,600
it really drives the relationship
441
00:18:18,600 --> 00:18:22,020
between binary and hex so let's jump
442
00:18:22,020 --> 00:18:24,020
into this
443
00:18:24,020 --> 00:18:25,730
so the trick here is to match the first
444
00:18:25,730 --> 00:18:28,490
four binary numbers with the first hex
445
00:18:28,490 --> 00:18:31,040
digit in the last four with the last hex
446
00:18:31,040 --> 00:18:32,690
digit you can see the number down here
447
00:18:32,690 --> 00:18:35,630
as I type it out
448
00:18:35,630 --> 00:18:38,929
so here we want to make a seven using
449
00:18:38,929 --> 00:18:41,150
these first four and a four which is
450
00:18:41,150 --> 00:18:44,510
going to be this bit FF is super easy
451
00:18:44,510 --> 00:18:47,990
every bit gets set here we 1e
452
00:18:47,990 --> 00:18:50,360
here we one a seven and at some point
453
00:18:50,360 --> 00:18:51,890
you can do this without really thinking
454
00:18:51,890 --> 00:18:55,809
right it's not too bad
455
00:18:55,809 --> 00:18:58,580
it looks overwhelming and that's kind of
456
00:18:58,580 --> 00:18:59,809
the whole point of it is it's not
457
00:18:59,809 --> 00:19:02,150
overwhelming and once you get into it
458
00:19:02,150 --> 00:19:06,370
you can convert the stuff in your head
459
00:19:07,420 --> 00:19:08,680
next game I wanted to point out is
460
00:19:08,680 --> 00:19:10,540
squally there's a minigame in squally
461
00:19:10,540 --> 00:19:13,390
that drills in binary decimal and Hexter
462
00:19:13,390 --> 00:19:15,880
gameplay so here we have blue cards that
463
00:19:15,880 --> 00:19:19,290
are binary green cards they're hex and
464
00:19:19,290 --> 00:19:21,820
white cards that are decimal and to
465
00:19:21,820 --> 00:19:23,140
learn how they work through standard
466
00:19:23,140 --> 00:19:25,150
game play you just made my card weaker
467
00:19:25,150 --> 00:19:28,740
and that's all there is to it
468
00:19:28,740 --> 00:19:30,870
and of course links to both of these
469
00:19:30,870 --> 00:19:34,169
will be in the description so last time
470
00:19:34,169 --> 00:19:35,580
we left off with this as our
471
00:19:35,580 --> 00:19:37,470
understanding of what a computer program
472
00:19:37,470 --> 00:19:40,799
was but now let's update it so before we
473
00:19:40,799 --> 00:19:43,440
know that there's groups of eight bits
474
00:19:43,440 --> 00:19:46,080
they can be addressed so the first group
475
00:19:46,080 --> 00:19:49,190
is zero the next group is one and so on
476
00:19:49,190 --> 00:19:52,320
to represent larger numbers we can use
477
00:19:52,320 --> 00:19:55,020
more groups of bits so at the top here
478
00:19:55,020 --> 00:19:57,270
we have this giant group of eight or
479
00:19:57,270 --> 00:19:59,370
eight groups of eight bits which
480
00:19:59,370 --> 00:20:02,070
represents that giant seven nine nine
481
00:20:02,070 --> 00:20:04,080
five number and then there's smaller
482
00:20:04,080 --> 00:20:06,120
groups right this group of one that
483
00:20:06,120 --> 00:20:10,130
represents the value 101 at address 169
484
00:20:10,130 --> 00:20:13,620
so let's take this idea and now we're
485
00:20:13,620 --> 00:20:15,960
going to replace those with hex numbers
486
00:20:15,960 --> 00:20:19,529
so hex can be used to represent binary
487
00:20:19,529 --> 00:20:21,360
numbers and it's a little more human
488
00:20:21,360 --> 00:20:24,299
readable so will almost never look at
489
00:20:24,299 --> 00:20:26,970
binary again will probably always be
490
00:20:26,970 --> 00:20:29,549
using hex except for a few exceptions in
491
00:20:29,549 --> 00:20:31,799
the future what used to be groups of
492
00:20:31,799 --> 00:20:33,899
eight binary digits are now represented
493
00:20:33,899 --> 00:20:37,559
by two hex digits and I'll point a few
494
00:20:37,559 --> 00:20:39,090
examples out to make sure that this is
495
00:20:39,090 --> 00:20:41,669
clear so the group of numbers with the
496
00:20:41,669 --> 00:20:45,600
value 623 is using 32-bit bits of
497
00:20:45,600 --> 00:20:48,870
information or 4 bytes and the yellow
498
00:20:48,870 --> 00:20:50,880
group numbers is using 16 bits of
499
00:20:50,880 --> 00:20:54,539
information or 2 bytes and if it's still
500
00:20:54,539 --> 00:20:56,460
confusing I recommend comparing it with
501
00:20:56,460 --> 00:20:59,399
the previous screenshot anyhow I hope
502
00:20:59,399 --> 00:21:00,659
you learned something about how binary
503
00:21:00,659 --> 00:21:03,779
numbers and hex work and as usual if you
504
00:21:03,779 --> 00:21:05,370
need anything clarified or have any
505
00:21:05,370 --> 00:21:09,260
feedback drop a comment below thank you
36187
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.