Download 2.4 - Nature & Capabilities of Software

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Large numbers wikipedia , lookup

Ethnomathematics wikipedia , lookup

Elementary arithmetic wikipedia , lookup

Elementary mathematics wikipedia , lookup

Arithmetic wikipedia , lookup

Addition wikipedia , lookup

Approximations of π wikipedia , lookup

Location arithmetic wikipedia , lookup

Positional notation wikipedia , lookup

Transcript
Number Bases
In today’s lesson we will look at:
• what we mean by a number base
• how ordinary numbers work
• a number system called binary
• why binary is useful
• other bases
What is a Number Base?
•
A number base is a method for writing down
numbers
•
For example, we normally use a number system
called base 10 (also sometimes called denary or
decimal), which is all based on the number 10
•
Some people think that we developed a number
system based on tens because we have ten fingers
•
You might also know other number systems, e.g.
roman numerals or tallies (as used in tally charts)
•
We are only talking about how numbers are written
down – this doesn’t change the way numbers work
Recording Numbers
Four
IIII
IV
Pedwar
All of these words and marks
mean the same thing.
Vier Quatre
The Decimal System
The number system most of us use is based on tens:
x10
x10
x10
1000
100
10
1
1
2
3
4
In each column
we can have
ten different
digits (1 to 9
and 0)
As we move left, the
column headings
increase by a factor
of ten
This number is:
1 x 1000 + 2 x 100 + 3 x 10 + 4 x 1
That gives us one thousand
two hundred and thirty four
Binary
The binary system is the same, but is based on two:
x2
x2
x2
8
4
2
1
1
0
1
1
In each column
we can have
two different
digits (0 or 1)
As we move left, the
column headings
increase by a factor
of two
This number is:
8 + 2 + 1 = 11
It’s still eleven, it’s just written
down differently
Largest Numbers
1000
100
10
1
0
0
0
9
1000
100
10
1
0
0
9
9
8
4
2
1
0
1
1
1
If we make the
largest number we
can with a given
number of digits, the
total is one less than
the next column
heading
Binary behaves in
the same way – e.g.
111 is seven.
Shifting Digits
1000
100
10
1
0
0
2
5
0
2
5
0
8
4
2
1
0
0
1
1
0
1
1
0
If we shift the
digits left one
place, a standard
number gets ten
times bigger.
Doing the same
thing in binary
makes the number
two times bigger
e.g. 11 is three
and 110 is six.
Why Use Binary?
•
Computers haven’t got fingers, but they have got
circuits that can be on or off
•
We can use on to represent 1 and off to represent 0
and use these circuits to process binary numbers
•
Everything inside the computer, therefore, is done in
the form of binary
•
Binary numbers can be sent along cables as pulses of
electricity (where a pulse would be 1, and a gap is 0)
•
If you used your hands to count using binary (finger
up = 1, down = 0), you could count up to 1023 on your
ten fingers!
Anything Else?
•
You might have noticed that lots of numbers to do
with computers are multiples of 2 – e.g. you can get
iPods with 8Gb, 16Gb, 32Gb, etc, of storage, rather
than 10Gb, 20Gb, 30Gb, etc.
•
Numbering things with multiples of two (1, 2, 4, 8,
16, etc.), rather than sequentially (1, 2, 3, 4, 5),
gives them an interesting property…
•
…any given combination gives a unique total that
can only come from that one combination
•
This can be used to create things called binary
flags
Other Bases
Hexadecimal is sometimes used; it’s based on sixteens:
x16
x16
x16
4096
256
16
1
0
1
2
3
As we move left, the
column headings
increase by a factor
of sixteen
This number is:
In each column
we can have
sixteen
different digits
1 x 256 + 2 x 16 + 3 x 1 = 291
It’s still two hundred and ninetyone, it’s just written down differently
Wait a Minute...
•
How can there be sixteen possible digits in each
column, when there are only ten digits?
•
Hexadecimal uses the digits 0-9 and the letters A-F,
so counting would look like this:
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
30 31 32 32 … etc
Why Use Hexadecimal?
•
Hexadecimal numbers are shorter than their
decimal equivalents, and use fewer digits.
•
For example, a two digit number can be up to FF,
which is 255
•
Hexadecimal is most often used to describe colours,
especially when editing a web-page or adjusting the
palette in your painting program
•
Colour codes are made up of two digits each for the
amount of red, green and blue, in the form
#RRGGBB
•
e.g. #FF0000 is bright red, #FF00FF is purple, etc.