CS101 Lecture 3

Download Report

Transcript CS101 Lecture 3

CS101 Learning Binary
Learning Binary
What do you think when you
see..
• 101
• One hundred and one
• What does a computer think when it sees 101?
• 5
Computers are base 2 creatures
• Computers can only use 0’s and 1’s.
– Because their processors are made up of
switches.
• The base 2 number system uses the numbers
0-1, or 2 total numbers.
• Binary means 2. Therefore, computers use
the base 2, or binary number system
You are a base 10 creature
• You have learned the base 10 number
system.
• The base 10 number system uses the
numbers 0-9, or 10 total numbers.
Review base 10 number system
• Can only use numbers 0-9 in base ten system
– 10 different numbers allowed in a column in a base 10
system
• Columns have place value
– You start with the one’s column
– To find the next column to the left multiply the current
column by 10.
– …, thousands, hundreds, tens, ones
Good News
• All the base ten number system concepts
you have learned can be used to learn the
the base 2, or binary number system
• Except for:
You only get to use 2 numbers in base two
instead of the 10 numbers in base ten
Creating base 2 place value columns
• Columns have place value
– You start with the 1’s column
– To find the next column to the left multiply the
current column by the amount of numbers
allowed in the base system.
Base 10
…, 1000000, 100000, 10000, 1000, 100, 10, 1
Base 2
…, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1
Quiz Tip
• Many binary questions on the quiz will be
much easier if you can create the base two
columns.
Counting to 10 in base 2 and base 10
Base 10
0
1
2
3
4
5
6
7
8
9
10
Base 2
0
1
10
11
100
101
110
111
1000
1001
1010
iClicker
• What number is this 11?
–
–
–
–
A) Eleven
B) Three
C) I do not know until you tell me the base
D) None of the above
iClicker
• How would you write the value of eleven in
base two?
–
–
–
–
–
A) 11
B) 0011
C) 1100
D) 1011
E) 1111
Now that you know
base 2, you can
convert numbers
between base 2 and
base 10
•
Converting base 10 number
to
base
2
number
Write down your base 10 number
•
Write down your base 2 columns
– Keep going until the base 2 column number is larger than the base 10
number
•
Find biggest base 2 column that is equal to or smaller than base 10 number
•
Add one set to that base 2 column and subtract the amount of the base 2 column
from base 10 number
•
Find the next biggest base 2 column that is equal to or smaller than the
remaining base 10 number.
– If you skip over any base two columns place zeros in them
•
When you find the next base 2 column that is equal to or less then the remaining
base 10 number add one set to that base 2 column and subtract the amount of the
base 2 column from the remaining base 10 number.
•
Keep repeating process until the base 10 number is down to zero.
•
Place zeros in any remaining base 2 columns
iClicker
• Which base 2 number below is equal to the
base 10 number 65?
–
–
–
–
–
A) 1100111
B) 1000011
C) 1010110
D) 1010111
E) 1000001
Converting base 2 number
to base 10 number
• Write down your base 2 number
• Write down your base 2 columns on top of
the base 2 number
• Determine which columns have a set on one
in them and write down each column’s
value as a base 10 addition problem
• Add up the values of your columns and you
have your base 10 number
iClicker
• Which base 10 number below is equal to the
base 2 number 101101?
–
–
–
–
–
A) 4
B) 16
C) 45
D) 56
E) 256
Using your base 2 knowledge
(and practice for quiz)
• http://forums.cisco.com/CertCom/game/bin
ary_game_page.htm