Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Binary

Similar presentations


Presentation on theme: "Introduction to Binary"— Presentation transcript:

1 Introduction to Binary

2 Why Bother with Binary? This is all about electronics
We don’t use binary because electronics do We designed electronics to use binary because it is very easy to do so Trying to use decimal inside electronics would be crazy difficult

3 Why Bother with Binary? Operations are easy in electronics (just wait!) Binary numbers can be used to represent anything

4 Why Bother with Binary? Operations are easy in electronics (just wait!) Binary numbers can be used to represent anything Numbers!

5 Why Bother with Binary? Operations are easy in electronics (just wait!) Binary numbers can be used to represent anything Numbers! π = [and more!]

6 Why Bother with Binary? Operations are easy in electronics (just wait!) Binary numbers can be used to represent anything Numbers! π = [and more!] Words “To be, or not to be!” Pictures Videos

7 Why Bother with Binary? Operations are easy in electronics (just wait!) Binary numbers can be used to represent anything Numbers! π = [and more!] Words “To be, or not to be!” Pictures Videos Programs (like games!)

8 Number Systems Ways to organize and write numbers Set of digits
Set of operations Addition Subtraction

9 Number Systems – Decimal
Digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Operations Addition ( ) Subtraction ( 5 – 3 )

10 Number Systems – Decimal
Written Form Every “place” is 10 times the place to the right Number 1000 100 10 1 17 7 51 5 5281 2 8

11 Number Systems – Decimal
What’s going on, here? 1000 * 5 * 2 * 8 * 1 = 5281 Number 1000 100 10 1 5281 5 2 8

12 Number Systems – Binary
Digits 0, 1 Operations Addition ( ) Subtraction ( 101 – 011 ) Fun new things (and, or, not, xor)

13 Number Systems – Binary
States can be easily represented in electronics Off False On True 1

14 Number System - Binary Written Form
Every “place” is twice the place to the right Number 4096 2048 1024 512 256 128 64 32 16 8 4 2 1 17 51 5281

15 Number Systems – Binary
Same number as before = Number 4096 2048 1024 512 256 128 64 32 16 8 4 2 1 5280

16 Familiar Numbers Decimal: 25 Binary: 11001 10 * 2 + 1 * 5 25 10000
11001 Number 1000 100 10 1 25 2 5 Number 128 64 32 16 8 4 2 1 11001

17 Converting to Binary Decimal 128 64 32 16 8 4 2 1 Binary 29 00011101
31 33 100 111 125

18 Binary Numbers Just another way to “write” the numbers you see every day

19 Numbers with Meaning How do we represent words in computers?

20 Numbers with Meaning How do we represent words in computers? Numbers!

21 Numbers with Meaning How do we represent words in computers? Numbers!
(Bet you didn’t see what one coming...)

22 ASCII American Standard Code for Information Interchange
A special set of numbers to represent letters All letters have a number assigned to them

23 ASCII □■□□□□□■ □■□□■■■■ □■□□□□■□ P 80 □■□■□□□□ □■□□□□■■ □■□■□□□■
Letter Decimal Binary Pattern A 65 □■□□□□□■ O 79 □■□□■■■■ B 66 □■□□□□■□ P 80 □■□■□□□□ C 67 □■□□□□■■ Q 81 □■□■□□□■ D 68 □■□□□■□□ R 82 □■□■□□■□ E 69 □■□□□■□■ S 83 □■□■□□■■ F 70 □■□□□■■□ T 84 □■□■□■□□ G 71 □■□□□■■■ U 85 □■□■□■□■ H 72 □■□□■□□□ V 86 □■□■□■■□ I 73 □■□□■□□■ W 87 □■□■□■■■ J 74 □■□□■□■□ X 88 □■□■■□□□ K 75 □■□□■□■■ Y 89 □■□■■□□■ L 76 □■□□■■□□ Z 90 □■□■■□■□ M 77 □■□□■■□■ ! 33 □□■□□□□■ N 78 □■□□■■■□ ? 63 □□□■■■■■ Letter Decimal Binary Pattern A 65 □■□□□□□□■ B 66 C 67 D 68 E 69 F 70 G 71 H 72 I 73 J 74 K 75 L 76 M 77 N 78 O 79

24 Making Words From Letters
How do we write our ABCs?

25 Making Words From Letters
How do we write our ABCs? Like this: □■□□□□□■□■□□□□■□□■□□□□■■

26 Making Words From Letters
How do we write our ABCs? Like this: □■□□□□□■□■□□□□■□□■□□□□■■ How about XYZ?

27 Making Words From Letters
How do we write our ABCs? Like this: □■□□□□□■□■□□□□■□□■□□□□■■ How about XYZ? □■□■■□□□□■□■■□□■□■□■■□■□

28 Can You Write Your Initials?
Letter Decimal Binary Pattern A 65 □■□□□□□■ O 79 □■□□■■■■ B 66 □■□□□□■□ P 80 □■□■□□□□ C 67 □■□□□□■■ Q 81 □■□■□□□■ D 68 □■□□□■□□ R 82 □■□■□□■□ E 69 □■□□□■□■ S 83 □■□■□□■■ F 70 □■□□□■■□ T 84 □■□■□■□□ G 71 □■□□□■■■ U 85 □■□■□■□■ H 72 □■□□■□□□ V 86 □■□■□■■□ I 73 □■□□■□□■ W 87 □■□■□■■■ J 74 □■□□■□■□ X 88 □■□■■□□□ K 75 □■□□■□■■ Y 89 □■□■■□□■ L 76 □■□□■■□□ Z 90 □■□■■□■□ M 77 □■□□■■□■ ! 33 □□■□□□□■ N 78 □■□□■■■□ ? 63 □□□■■■■■

29 Bonus Can you decode the binary code on my shirt?

30 Arithmetic in Binary Easy
You only need to know how to add 0 and 1 Hardest operation you ever have to do is 1 + 1 Hint: the answer isn’t “2”

31 Addition – Decimal 2 + 2 = 2 + 8 = 7 + 8 =

32 Addition – Binary 0 + 0 = 0 + 1 = 1 + 0 = 1 + 1 =

33 Addition – Binary 10 + 10 = ( 2 + 2 ) 10 + 1000 = ( 2 + 8 )
= ( ) = ( ) = ( ) = ( )

34 Funny Operators And 0 ∧ 0 = 0 0 ∧ 1 = 0 1 ∧ 0 = 0 1 ∧ 1 = 1 Or

35 Programs in Binary Everything in a computer is represented with binary numbers Programs in a computer are (of course!) represented in binary numbers

36 Programs in Binary Instructions Program Storage
List of things you can do Program List of instructions, in order Storage Instructions, encoded into binary, in the computer’s memory

37 Programs in Binary - Instructions
Human Robots Just like our first week in Coding Club Can move forward Can turn right Can turn left

38 Programs in Binary Program Move forward Turn left Turn right etc.

39 Programs in Binary Instructions .. in binary! We have 3 instructions
We will need two “bits” for each instruction 2 bits can represent 0, 1, 2, or 3 in decimal We only need 3 of these 4; one of them will be unused

40 Programs in Binary Instructions .. in binary! Turn left: 01
Turn right: 10 Move forward: 11

41 Programs in Binary Program Instructions Move forward Turn left
Turn right etc. Instructions 11 01 10 etc.

42 Programs in Binary Program in computer memory 111101111011 or
■■■■□■■■■□■■

43 How Does a Computer Run a Program?
Program is in memory ■■■■□■■■■□■■ Computer knows all instructions are 2-bits wide Computer starts at the beginning Read 2 bits Decide which instruction is represented Perform instruction (e.g. turn, move) Repeat

44 Complicated Programs Human Robots Real Computer Programs
Limited to turn, move Real Computer Programs Can do much more

45 Complicated Programs Perform arithmetic Make decisions Run loops
Load/store information

46 Complicated Programs Require lots of instructions Examples:
load, store add, subtract compare jump!

47 Complicated Programs Instructions Instructions Load Add Jump
Jump-if-equal Instructions 0001 0011 0101 0110

48 Complicated Programs Instructions Instructions Extra Load Add Jump
Jump-if- equal Instructions 0001 0011 0101 0110 Extra What? Where? What/Where ?

49 Let’s Count to Ten Instructions Instructions Extra Load Add Jump
Jump-if- equal Instructions 0001 0011 0101 0110 Extra 0000 0001 0101 1010

50 Let’s Count to Ten Instructions Instructions Extra Load Add Jump
Jump-if- equal Instructions 0001 0011 0101 0110 Extra 0000 0001 0101 1010

51 Let’s Count to Ten Instructions Instructions Extra Load Add Jump
Jump-if- equal Instructions 0001 0011 0101 0110 Extra 0000 0001 0101 1010 code code code code

52 Let’s Count to Ten Instructions Instructions Extra Load Add Jump
Jump-if- equal Instructions 0001 0011 0101 0110 Extra 0000 0001 0101 1010 data data data data data

53 Complicated Programs Instructions Instructions Extra Load Add Jump
Jump-if- equal Instructions 0001 0011 0101 0110 Extra 0000 0001 0101 1010 data data data data data ?

54 } Complicated Programs Instructions Instructions Extra Load Add Jump
Jump-if- equal Instructions 0001 0011 0101 0110 Extra 0000 0001 0101 1010 } data data data data data

55 } { Complicated Programs Instructions Instructions Extra Load Add Jump
Jump-if- equal Instructions 0001 0011 0101 0110 Extra 0000 0001 0101 1010 } code data code data code data data code data {

56


Download ppt "Introduction to Binary"

Similar presentations


Ads by Google