JF_Basesx (Slides)
Download
Report
Transcript JF_Basesx (Slides)
KS3: Bases
Dr J Frost ([email protected])
Objectives:
1. To appreciate how we can have different number systems using
different ‘bases’.
2. Count in different bases.
3. To convert numbers from decimal to another base.
4. To convert numbers from any base to decimal.
Last modified: 22nd June 2016
Starter
Can you spot any patterns in how we’re counting up? How
does this pattern relate to the ‘base’?
Base 10
Base 2
5
6
7
8
9
10
11
12
…
0
1
10
11
100
…
Base 3
Base 5
Base 2
Base 16
2
10
11
12
20
21
…
344
400
401
402
…
111
1000
1001
1010
…
99
9A
9B
9C
9D
9E
9F
A0
…
Things you might have spotted:
• The maximum value for any digit is one less than the base.
• When we get to the maximum value for a digit, it resets back to 0, and the next digit
?
(left of it) goes up by 1.
Introduction
When we count up with ‘normal’ numbers, what is actually
happening at the indicated points?
6
7
8
9
10
11
12
…
The maximum
value for a digit is
9. So it resets to 0,
and the units
? digit
goes up by 1
because of the
‘carry’.
97
98
99
100
101
…
Both digits are at
their maximum so
both reset
? back to
0. The hundreds
digit goes up by 1.
Follow up question:
• What do you think it means for our ‘normal’ number system to be base 10?
Each digit has 10 possible values.
?
Base
!
The base of a number system is the number of possible values
for each digit.
Values for each
digit
0 to 9
0 to 1
0 to F
(A=10, B=11, ... F=15)
Base
10
2
16
?
?
?
Name of
number system
Decimal?
Binary ?
Hexadecimal
?
Example of counting
We want to count in base 2 (binary).
We saw the possible values for each digit are 0 to 1.
0
1
10
11
100
101
110
111
1000
1010
1111
Next number?
Counting Game!
Everyone stand up. Take it in turns to count in ternary (base 3), starting at 0. If you get it
wrong, you sit down.
0
1
2
10
11
12
20
21
22
100
101
102
110
111
112
120
121
122
200
201
202
210
211
212
220
221
222
1000
1001
1002
1010
1011
1012
1020
1021
1022
1100
1101
1102
1110
1111
1112
1120
1121
1122
1200
1201
1202
1210
1211
1212
1220
1221
1222
2000
2001
2002
2010
2011
2012
2020
Exercise 1
1
Write out the first ten numbers in each of these bases, starting at 1.
a
Base 2: 1, 10, 11, 100, 101, 110, ?
111, 1000, 1001, 1010
b
Base 5: 1, 2, 3, 4, 10, 11, 12, 13, ?
14, 20
c
Base 4: 1, 2, 3, 10, 11, 12, 13, 20,?21, 22
2
a
b
What number comes after 555 in:
Base 6? 1000
?
Base 7? 556
?
NN How many times does the digit 0 occur if you write out the numbers 1 to 111111
in binary? (Hint: consider all two-digit numbers, then three, and so on)
2 digit numbers: 𝟏 × 𝟏 = 𝟏 occurrence
You can see the first numbers are powers of 2 and the
second are going up by 1 each time.
3 digit numbers: 𝟐 × 𝟐 = 𝟒 occurrences
Why: Consider just 5 digit numbers. There are 25−1 = 16
4 digit numbers: 𝟒 × 𝟑 = 𝟏𝟐 occurrences
possible numbers (because the first digit has to be 1 but
the other digits each have two possibilities). For each
5 digit numbers: 𝟖 × 𝟒 = 𝟑𝟐 occurrences ?
digit half of the possibilities will be 0, thus each digit
6 digit number: 𝟏𝟔 × 𝟓 = 𝟖𝟎 occurrences
(except the first) contributes 16 ÷ 2 = 8 zeros. There’s 4
digits which contributes zeroes, thus 8 × 4 = 32.
Total = 129
𝑘−2
In general for 𝑘 digit numbers, 2
be seen.
× (𝑘 − 1) zeroes will
Any Base → Decimal
If we were to write out the digits of the decimal
number “2493”, what is the value of each digit?
(Hint: Think primary school!)
1000 100? 10
multiply
1
2 4 9 310
?
2000 +400 +90?+ 3 = 2493
This means number
is in base 10. We
don’t include it if
the base is obvious
from the context.
Any Base → Decimal
Now suppose we had a number in base 5 instead.
How do we convert it to decimal?
125 25 ? 5
multiply
1
4 3 0 15
500 + 75 + 0 ?+ 1 = 576?
Test Your Understanding
Copy and complete in your book.
8
4
?2
64 16 ? 4
1
1 0 1 12
8 + 0 +? 2 + 1 = 11
27 9 ?3
1
3 3 0 24
192 + 48 + ? 0 + 2 = 242
1
1 2 2 03
27 + 18 +? 6 + 0 = 51
The Maya numeral system is base 20
(“vigesimal”).
Use the approach you used for
converting other bases to decimal to
vote for the correct number.
Example
20
60
3
30
1
+
0
= 0
60
300
Q1
20
120
66
126
1
+
6
= 126
105
156
Q2
123
243
53
223
Q3
239
144
129
1
Q4
400
400
121
20
+
211
0
1
+
11 = 411
111
411
Q5
490
1180
1980
1380
Q6
8000
152000
157784
400
+
5600
582984
20
+
180
=
396884
1
+4
196884
Exercise 2
1
Convert the following numbers from
the indicated base to decimal.
11012
1112
1100112
10223
7348
2335
5306
2
13
7
51
35
476
68
198
?
?
?
?
?
?
?
What is the following Mayan number
in decimal?
4
?
5
When the number “a036” in base 7
is converted to decimal, the value is
1742. Determine the value of the
digit 𝑎.
𝟑𝟒𝟑𝒂 + 𝟎 + 𝟐𝟏 + 𝟔 = 𝟏𝟕𝟒𝟐
𝒂=𝟓
?
In general, what is the largest number in decimal that
can be represented by 𝑛 binary digits? Give your
answer in terms of 𝑛.
𝟐𝒏 − 𝟏
?
6
A three-digit number is 100 in decimal. What’s the
smallest the base can be?
In base 4 the biggest number in decimal is 𝟒𝟑 − 𝟏 =
𝟔𝟑, whereas in base 5 it’s 𝟓𝟑 − 𝟏 = 𝟏𝟐𝟒. So 5 is the
smallest base.
?
N
160?001
3
In computing, a byte consists of 8 bits, where each bit
is a binary digit. What is the largest possible number
in decimal that a byte can represent?
𝟐𝟓𝟓
The number with digits "𝑎1𝑏", where 𝑎 and 𝑏 are
unknown digits, is 107 in decimal if the number was
originally in base 5, and 205 in decimal if it was
originally in base 7. Determine 𝑎 and 𝑏.
𝟐𝟓𝒂 + 𝟓 + 𝒃 = 𝟏𝟎𝟕
𝟒𝟗𝒂 + 𝟕 + 𝒃 = 𝟐𝟎𝟒
Solving, 𝒂 = 𝟒, 𝒃 = 𝟐.
?
N
432 is in an unknown base, but when converted to
decimal, gives 164. Determine the base.
Let the base be 𝒃. Then 𝟒𝒃𝟐 + 𝟑𝒃 + 𝟐 = 𝟏𝟔𝟒.
Solving this quadratic equation gives 𝒃 = 𝟔.
?
Summary So Far
We have learnt that the numbers we use in everyday life are in
“base 10”.
?
But numbers can be in any ‘base’ such as base 2 (binary).
?
The base of a number system is
the number of possible
? values for each digit.
To convert a number to decimal, we just consider the value of
each digit, just like in decimal each digit represents “units”, “tens”,
“hundreds” and so on.
14035 = 𝟏𝟐𝟓 + 𝟏𝟎𝟎?+ 𝟑 = 𝟐𝟐𝟖
Decimal → Any Base
Do the opposite! Convert 18 from decimal to binary.
16
8
?4
2
1
1? 0? 0? 1 0 2
?
?
16 + 0 + 0 + 2 + 0 = 18
Bro Tip: Start with the highest multiple possible of the
highest power (in this case 16). Then see what’s left and
continue to get the digits.
Another Example
Convert 272 for decimal to base 5.
125
25
?
5
1
2? 0 4 2
?
?
?
5
250+ 0 + 20+ 2= 272
Test Your Understanding
Convert 100 from decimal to base 4.
?
64
16
4
1
1?
2? 1? 0?
4
64 +32 + 4 + 0 = 100
Decimal → Any Base
It can help to write out multiples of your various powers. Below is base 6.
Multiples of 6
x1
x2
x3
x4
x5
6
12
18
24
30
c. We can only
have 1 lot of 6.
Multiples of 62
Multiples of 63
36
72
108
144
180
216
432
648
864
1080
b. We can have
4 lots of 62.
Therefore what is 800 is base 6?
?
3412
a. We can have
3 lots of 63.
Exercise 3
1
Copy and complete the
following table.
Decimal Binary (Base 2)
3
?
8
10
77
102
105?
1365
2
11
?
1010 ?
1001101
?
1100110
?
1101001
?
10101010101
?
1000
3
?
12 ?
14 ?
205?
250?
N
10153
?
a horizontal line means 5, a dot 1 and a shell 0).
1000 is a four-digit decimal number
whose first digit one. In what other
bases can this can be converted to such
that we still have a four-digit number
which starts with 1?
If the base is 𝒃, 𝒃𝟑 has to be between
500 and 1000 (if it were less, the first
digit wouldn’t be 1). Only 8 and 9
satisfy this.
?
253
Convert 123 in decimal to Mayan
numerals (recall that Mayan is base 20, and that
?
?
Base 6
3
The decimal number “7a2” is 10322 in
base 5. Determine the digit 𝑎.
𝒂=𝟏
N
Prove that there is no base 𝑏 such that
123 in decimal can be converted to:
i. 45 in that base.
𝟒𝒃 + 𝟓 = 𝟏𝟐𝟑
𝟓𝟗
𝒃=
𝟐
ii. 456 in that base.
𝟒𝒃𝟐 + 𝟓𝒃 + 𝟔 = 𝟏𝟐𝟑
Solving gives 𝒃 = 𝟒. 𝟖𝟐, −𝟔. 𝟎𝟕,
neither or which are integers.
?
?
Decimal → Hexadecimal
The most well-known usage of hexadecimal is to represent colours.
Each colour can be
composed of red, green and
blue light, each of intensity
varying between 0 and 255.
...which can be represented
using just 6 digits in
hexadecimal, 2 for each of the
three colour components.
A means 10, B means 11, ...
F means 15
Multiples
of 16:
0:
1:
2:
3:
4:
5:
6:
7:
8:
9:
A:
B:
C:
D:
E:
F:
0
16
32
48
64
80
96
112
128
144
160
176
192
208
224
240
RED
GREEN
BLUE
HEXADECIMAL
255
255
255
FF, FF, FF
0?
0?
0?
? 00
00, 00,
0?
?
255
0?
? 00
00, FF,
?
255
?
255
0?
? 00
FF, FF,
?
75
?
172
?
198
? C6
4B, AC,
?
255
?
128
0?
? 00
FF, 80,
Adding in decimal
+
2
3
0
6
5
1
3
9
3 + 9 = 12
We’d use the 2 then carry the 1.
Adding in other bases
+
1
?
1
1
0
?
0
1
1
?
0
0
1
?
1
1
1
0
?
Another Example
+ 1
1 0
1
1
0
?
0
0
1
1
1
0
0
1
1
Test Your Understanding
1
+
1
0
1
1
1?
0
1
0
1
1
0
2
+
3
3
2
0?
0
2
3
35
45
2
Exercise 4
Convert the following to hexadecimal.
QQQ Time
1a The number of possible
values each ?digit can
have.
4
3900
?
5
11011
?
6
2400
?
7
100100
?
8
a = 2, b =?4
1b Because each digit must
be between 0 and one
less than the? base/the
digits must be less than
the base.
2a 2
?
2b 178
?
551
?
3