-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinOctHex.html
More file actions
546 lines (507 loc) · 10.3 KB
/
Copy pathbinOctHex.html
File metadata and controls
546 lines (507 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Binary Representation</title>
<!-- metadata -->
<meta name="generator" content="S5" />
<meta name="version" content="S5 1.1" />
<meta name="presdate" content="20050728" />
<meta name="author" content="Eric A. Meyer" />
<meta name="company" content="Complex Spiral Consulting" />
<!-- configuration parameters -->
<meta name="defaultView" content="slideshow" />
<meta name="controlVis" content="hidden" />
<!-- style sheet links -->
<link rel="stylesheet" href="ui/default/slides.css" type="text/css" media="projection" id="slideProj" />
<link rel="stylesheet" href="ui/default/outline.css" type="text/css" media="screen" id="outlineStyle" />
<link rel="stylesheet" href="ui/default/print.css" type="text/css" media="print" id="slidePrint" />
<link rel="stylesheet" href="ui/default/opera.css" type="text/css" media="projection" id="operaFix" />
<!-- S5 JS -->
<script src="ui/default/slides.js" type="text/javascript"></script>
<style type = "text/css">
table, td {
border: 1px solid black;
}
td {
width: 2em;
height: 1em;
}
</style>
</head>
<body>
<div class="layout">
<div id="controls"><!-- DO NOT EDIT --></div>
<div id="currentSlide"><!-- DO NOT EDIT --></div>
<div id="header"></div>
<div id="footer">
<h1>CSCI Dept Of computer Science</h1>
<h2>Binary Representation</h2>
</div>
</div>
<div class="presentation">
<div class="slide">
<h1>Binary Representation</h1>
<h2>CSCI 23000</h2>
<h3>Andy Harris</h3>
<h4>Indiana University / Purdue University - Indianapolis</h4>
</div>
<!--
<div class="slide">
<h1>[slide title]</h1>
<ul>
<li>[point one]</li>
<li>[point two]</li>
<li>[point three]</li>
<li>[point four]</li>
<li>[point five]</li>
</ul>
<div class="handout">
[any material that should appear in print but not on the slide]
</div>
</div>
<div class="slide">
<h1></h1>
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<div class="handout">
</div>
</div>
-->
<div class = "slide">
<h1>Computers and Information</h1>
<ul>
<li>Information limited to on/off impulses</li>
<li>Like a light switch</li>
<li>Infinite positions</li>
<li>Two outcomes</li>
</ul>
</div>
<div class = "slide">
<h1>Working with Multiple Switches</h1>
<ul>
<li>The <a href = "http://wally.cs.iupui.edu/n351/binary/binLights.html">
light switch</a> demo</li>
<li>One switch - two messages</li>
<li>Two switches - four messages</li>
<li>Three switches - eight messages</li>
</ul>
</div>
<div class = "slide">
<h1>Assigning values to messages</h1>
<ul>
<li>Looking at the pattern </li>
<li>1, 2, 4, 8, 16, 32, 64, 128...</li>
<li>Seeing how it works</li>
<li>The <a href = "http://wally.cs.iupui.edu/n351/binary/legoMover.html">
brick counter</a> demo</li>
</ul>
</div>
<div class = "slide">
<h1>Converting from Binary to base 10</h1>
<ul>
<li>Start with Grid</li>
<li>Right to left</li>
<li>Powers of Two</li>
<li>Substitute 1 with appropriate value</li>
</ul>
</div>
<div class="slide">
<h1>Example: 1110</h1>
<ul>
<li>build grid:</li>
<li>
<table border = "1">
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>1</td>
<td>0</td>
</tr>
</table>
</li>
</ul>
</div>
<div class="slide">
<h1>Example: 1110</h1>
<ul>
<li>define powers of two:</li>
<li>
<table border = "1">
<tr>
<td>128</td>
<td>64</td>
<td>32</td>
<td>16</td>
<td>8</td>
<td>4</td>
<td>2</td>
<td>1</td>
</tr>
<tr>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>0</td>
</tr>
</table>
</li>
</ul>
</div>
<div class="slide">
<h1>Example: 1110</h1>
<ul>
<li>Multiply power by value:</li>
<li>
<table border = "1">
<tr>
<td>128</td>
<td>64</td>
<td>32</td>
<td>16</td>
<td>8</td>
<td>4</td>
<td>2</td>
<td>1</td>
</tr>
<tr>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>0</td>
</tr>
<tr>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>8</td>
<td>4</td>
<td>2</td>
<td>0</td>
</tr>
</table>
</li>
<li>8 + 4 + 2 = 14</li>
<li>1110 (base 2) = 14 (base 10)
</ul>
</div>
<div class = "slide">
<h1>Converting from Base 10 to Binary</h1>
<ul>
<li>Start with grid</li>
<li>Find highest value</li>
<li>Subtract</li>
<li>Repeat</li>
</ul>
</div>
<div class="slide">
<h1>Example: Convert 14(10) to binary</h1>
<ul>
<li>Build the powers of two</li>
<li>
<table>
<tr>
<td>128</td>
<td>64</td>
<td>32</td>
<td>16</td>
<td>8</td>
<td>4</td>
<td>2</td>
<td>1</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</li>
<li>14</li>
</ul>
</div>
<div class="slide">
<h1>Example: Convert 14(10) to binary</h1>
<ul>
<li>Can you subtract 128? 64? 32? 16?</li>
<li>Mark with 0 for 'no'</li>
<li>
<table>
<tr>
<td>128</td>
<td>64</td>
<td>32</td>
<td>16</td>
<td>8</td>
<td>4</td>
<td>2</td>
<td>1</td>
</tr>
<tr>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</li>
<li>14</li>
</ul>
</div>
<div class="slide">
<h1>Example: Convert 14(10) to binary</h1>
<ul>
<li>You can subtract 8</li>
<li>mark it with a one and subtract</li>
<li>
<table>
<tr>
<td>128</td>
<td>64</td>
<td>32</td>
<td>16</td>
<td>8</td>
<td>4</td>
<td>2</td>
<td>1</td>
</tr>
<tr>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</li>
<li>14 - 8 = 6</li>
</ul>
</div>
<div class="slide">
<h1>Example: Convert 14(10) to binary</h1>
<ul>
<li>Repeat with each digit (can you subtract 4 from 6?)</li>
<li>You'll always end at zero</li>
<li>
<table>
<tr>
<td>128</td>
<td>64</td>
<td>32</td>
<td>16</td>
<td>8</td>
<td>4</td>
<td>2</td>
<td>1</td>
</tr>
<tr>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>0</td>
</tr>
</table>
</li>
<li>14 - 8 - 4 - 2 = 0</li>
</ul>
</div>
<div class = "slide">
<h1>Binary is good...</h1>
<ul>
<li>Because it's the underlying format of computers</li>
<li>But</li>
<li>it's a pain to work with.</li>
<li>11001100001010 </li>
<li>Base 10 is more natural for humans</li>
<li>Conversion is tedious</li>
</ul>
</div>
<div class = "slide">
<h1>Base 8 (octal)</h1>
<ul>
<li>Rather than raising 10 or 2 to powers,</li>
<li>Use 8</li>
<li>123 base 8 =</li>
<li>
<pre>
3 * 8^0 (1) 3
+ 2 * 8^1 (8) 16
+ 1 * 8^2 (64) 64
==
83 base 10
</pre>
</li>
</ul>
</div>
<div class = "slide">
<h1>Base 8 characteristics</h1>
<ul>
<li>Max: 7</li>
<li>Min: 0</li>
<li>Possible values: 8</li>
</ul>
</div>
<div class = "slide">
<h1>3 Digits of binary</h1>
<ul>
<li>Max: 7</li>
<li>Min:0</li>
<li>Possible values: 8</li>
</ul>
</div>
<div class = "slide">
<h1>PATTERN!</h1>
<ul>
<li>Whatever can be expressed in 3 digits of binary...</li>
<li>Can be expressed in one digit of octal!</li>
<li>101 binary is 5 octal</li>
<li>010 binary is 2 octal</li>
</ul>
</div>
<div class = "slide">
<h1>3 digits binary = 1 digit octal</h1>
<ul>
<li>For three digits of binary, </li>
<li>converting to octal -</li>
<li>is just like converting to decimal</li>
</ul>
</div>
<div class = "slide">
<h1>Converting Binary to Octal</h1>
<ul>
<li>111011</li>
<li>Break into groups of 3 (from right)</li>
<li>111 011</li>
<li>Solve each group of three as an independent problem</li>
<li>
<pre>
421 421
111 011
7 3 octal
</pre></li>
</ul>
</div>
<div class = "slide">
<h1>Octal to Binary</h1>
<ul>
<li>45 base 8</li>
<li>Turn each octal digit to 3 digits of binary:</li>
<li>
<pre>
4 5 octal
421 421
100 101 binary
</pre></li>
</ul>
</div>
<div class = "slide">
<h1>The problem with Octal</h1>
<ul>
<li>Computers tend to work in bytes (8 bits)</li>
<li>Octal prefers lengths of 6 or 9</li>
<li>Eight bits fits in three digits of octal....</li>
</ul>
</div>
<div class = "slide">
<h1>But what about 643 octal?</h1>
<ul>
<li>It's possible to have a three digit octal </li>
<li>that doesn't fit in a byte.</li>
</ul>
</div>
<div class = "slide">
<h1>Four digits of Binary</h1>
<ul>
<li>Max: 15</li>
<li>Min: 0</li>
<li>Number of values: 16</li>
<li>This would be like base 16. (Hexadecimal)</li>
</ul>
</div>
<div class = "slide">
<h1>Converting Binary to Hex</h1>
<ul>
<li>10010111</li>
<li>Break to groups of four from right</li>
<li>
<pre>
8421 8421
1001 0111
9 7 hex
</pre></li>
</ul>
</div>
<div class = "slide">
<h1>But there's a problem...</h1>
<ul>
<li>What about this value?</li>
<li>1100</li>
<li>It comes out to 12 decimal,</li>
<li>But 12 hex means 16 +2 = 18!!</li>
</ul>
</div>
<div class = "slide">
<h1>We can't use base 10 place value here.</h1>
<ul>
<li>We must 'invent' new numerals</li>
<li>Letters can be used for numbers!</li>
</ul>
</div>
<div class = "slide">
<h1>The Sneaky Solution</h1>
<ul>
<li>10: A</li>
<li>11: B</li>
<li>12: C</li>
<li>13: D</li>
<li>14: E</li>
<li>15: F</li>
</ul>
</div>
</div>
</body>
</html>