Download Binar ry Dig gits

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

Addition wikipedia , lookup

Elementary mathematics wikipedia , lookup

Arithmetic wikipedia , lookup

Elementary arithmetic wikipedia , lookup

Approximations of π wikipedia , lookup

Positional notation wikipedia , lookup

Location arithmetic wikipedia , lookup

Transcript
Binarry Diggits
A Binary Diggit can only b
be 0 or 1 A Binary Nu
umber is mad
de up Binary Digits. Bits: In thee computer world "binaary digit" iss often shorttened to thee word "bit""
MoreTha
anOneDiigit
So, there aare only twoo ways you can
c have a bbinary digitt ("0" and "1
1", or "On"" and "Off") ... but
what aboutt 2 or more binary digitts?
Let's write them all doown, starting with 1 diggit (you can
n test it yourrself using tthe switchess):
2 ways to
t have one digit ...
0
1
... 4 ways to have two
o digits ...
1
0
1
0
1
0
1
0
1
0
0
1
t have threee digits ...
... 8 ways to
0
1
1
0
0
.... and 16 waays to have four digits.
→
→
→
→
0
1
0
1
0
1
0
0
1
1
000
001
110
111
→
→
→
→
→
→
→
→
0
1
0
1
0
1
0
1
→
→
→
→
→
→
→
→
000
001
010
011
100
101
110
111
0000
0001
0010
0011
0100
0101
0110
0111
0
0
1
1
0
1
1
0
1
0
1
0
1
0
1
→
→
→
→
→
→
→
→
1000
1001
1010
1011
1100
1101
1110
1111
And, in fact, we have created the first 16 binary numbers:
Decimal:
Binary:
0 1 2 3 4 5 6 7
8
9
10 11 12 13 14 15
0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111
This is quite a useful thing to remember. If you forget how the sequence of binary numbers go, just
think:
•
•
•
•
"0" and "1" {0,1}
then "0" and "1" again but with a "1" in front: {0,1,10,11}
then take those four with "1"s as a third digit: {0,1,10,11,100,101,110,111}
and so on!
(Or count in the same way as decimal numbers, but don't use 2,3,4,5,6,7,8 or 9.)
BinaryDigits...TheyDouble!
Also notice that each time you add another binary digit you double the possibilities. Why double?
Because you have to take all the previous possible positions and match them with a "0" and a "1"
like above.
So, if you had 5 things, then the total would be 32, 6 things would be 64, etc.
Using exponents this can be shown as:
No of Digits Formula
Settings
1 21
2
2 22
4
3 23
8
4 24
16
5 25
32
6 26
64
etc... etc...
etc...
Example: when you have 50 binary digits (or even 50 things that can only have two positions each),
how many different ways is that?
Answer 250 = 2 × 2 × 2 × 2 ... (fifty of these) = 1,125,899,906,842,624
So, a binary number with 50 digits could have 1,125,899,906,842,624 different values.
Or to put it another way, it could show a number up to 1,125,899,906,842,623 (note: this is one less
than the total number of values, because one of the values is 0).
ChessBoard
There is an old Indian legend about a King who was challenged to a
game of chess by a visiting Sage. The King asked "what will be the prize
if you win?".
The Sage said he would simply like some grains of rice: one on the first
square, 2 on the second, 4 on the third and so on, doubling on each
square. The King was surprised by this humble request.
Well, the Sage won, so how many grains of rice should he receive?
On the first square: 1 grain, on the second square: 2 grains (for a total of 3) and so on like this:
Square Grains
Total
1 1
1
2 2
3
3 4
7
4 8
15
10 512
1,027
20 524,288
1,048,575
30 53,6870,912
1,073,741,823
64 ???
???
By the 30th square you can see it is already a lot of rice! A billion grains of rice is about 25 tonnes
(1,000 grains is about 25g - I weighed some!).
Notice that the Total of any square is 1 less than the Grains on the next square (Example: square
3's total is 7, and square 4 has 8 grains). So the total of all squares is a formula: 2n-1, where n is the
number of the square. For example, for square 3, the total is 23-1 = 8-1 = 7
So, to fill all 64 squares in a chess board would need 264-1 = 18,446,744,073,709,551,615 grains
(460 billion tonnes of rice), many times more rice than in the whole kingdom.
So, the power of binary doubling is nothing to be taken lightly (460 billion tonnes is not light!)
(By the way, in the legend the Sage reveals himself to be Lord Krishna and tells the King that he
doesn't have to pay the debt immediately but can pay him over time, just serve rice to pilgrims
every day until the debt is paid off.)
Hexadecimal
Lastly, I would like to tell you about the special relationship between Binary and Hexadecimal.
There are 16 Hexadecimal digits, and we already know that 4 binary digits have 16 possible values.
Well, this is exactly how they relate to each other:
Binary: Hexadecimal: 0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111
0 1 2 3 4 5
6
7
8
9
A
B
C D E F
So, when people use computers (which prefer binary numbers), it is a lot easier to use the single
hexadecimal digit rather than 4 binary digits.
For example, the binary number "100110110100" is "9B4" in hexadecimal.
I know which I would prefer to write!