Computers store information by using switches (on-off switches, like
the ones used for turning on/off lights, except a lot smaller, and implemented
with electronics - i.e. no moving parts).

It works like this. Suppose you want to store some information. You go
down to the hardware store and buy a switch. OK, now you have a binary
digital storage device. "Digital" means basically that it only can have
one of a set number of possible states, and "binary" means that it can
only have two such possible states. That is, it can be either on or off.
An example of a device that is neither binary nor digital would be a slide
rule. Slide rules have an infinite number of possible states, and such
devices are called "analog" as opposed to "digital".

So far so good. You have a binary digital storage device. Now you just
have to decide how to represent information on it. You have two possible
states you can use, which means you can "store" two pieces of information
by specifying a "code".

Let's use numbers to represent the possible states of the switch. "0"
means the switch is off (up) and "1" means it is down. So let's make a
weather code.

0 = it's raining
1 = it's not

So now you have a personal digital assistant which stores the day's weather
report. So that's pretty cool, and you go out to show it to your friend.
You meet your friend, and pull out your switch and look at it (information
retrieval), remember the code (information processing) and say, "look,
according to my PDA, it is raining".

Your friend says, "that's nice...but as a matter of fact it stopped raining
an hour ago". And then she pulls out her PDA and shows you how she has
the very same info, plus a copy of War and Peace, stock market quotes,
and a complete mirror of "alt.liberal.arts.disgruntled". That's
because your friend's PDA has about 100 million more switches than yours.

So you are pretty crestfallen, and go back to the hardware store and
ask if they have 100 million switches in stock. They don't, they only
have 23. But that's a start, so you buy them and go back to your living
room, where you try to assemble them into a more powerful PDA.

Now you have 23 switches. How can you store more information? Well, since
you have more switches, your PDA can have more possible states. For example,
suppose you take two switches and put them side by side. Now, instead
of two possible states, you have four:

00
01
10
11

This is looking promising, so you put another switch alongside the other
two:

000
001
010
011
100
101
110
111

Now you have 8 possible combinations. If you think of it, every time
you add another switch, you are doubling the number of possible combinations,
thus doubling the amount of "information" you can hold. I put "information"
in quotes because it isn't really information until you specify what these
combinations are supposed to mean, in other words you need a code (keep
reading).

So, if you have n switches you have 2**n possible combinations.

By the way, if you want to know why I ordered the combinations above
the way that I did, the answer is, I was counting in binary, that is,
base 2. Counting in base 2 is just like counting in decimal, except that
each step to the left is another power of two, instead of a power of 10.

OK, let's line up our 23 switches and start storing some information.
We have 2**23 possible combinations, which is ... a lot.

00000000000000000000000 = "it's not raining"
00000000000000000000001 = "it's raining"
00000000000000000000010 = "the capital of the USA is New York City"
00000000000000000000011 = "disregard the statement in the previous record,
it is incorrect, although some people don't know that".

This could start getting out of hand.... Let's try something else: how
about just making a code for letters, and then storing only letters? It
will make our code a lot simpler, for one thing.

If we are going to store letters, we don't need to use all 23 switches
for a single letter. We wouldn't want to use all of our switches for a
single letter anyway, because then we can only store 1 letter in our PDA.

5 switches is enough for 26 letters, but then we can't specify upper/lower
case. Plus we want to specify digits (1,2,3 etc.) and punctuation too.
So we need at least 7 switches. We don't need more than that. We can arrange
the switches in groups of 7, and then can start storing information by
putting the code for a letter or other symbol in each 7-switch group.

Now, if we are going to make a code, it would be best if we also agree
with others on this code, that is, make it a convention. That way, we
can share devices (hardware) and information (software).

Better yet, check to see if someone has already made a code. Someone
has, it is called "ASCII". ASCII is a code made up by a group of computer
companies and industry representatives. They made an 8-switch code, probably
because grouping by 8 is a lot easier than grouping by 7, since 8 is an
even number. They used the extra switch for error checking. (This particular
error checking is called "parity" and is used when transferring bytes
between computers. That is done not by picking up the switch and throwing
to the other computer, (although that would work too), but by attaching
a wire between the computers and sending "0"s and "1"s by means of an
electronic signal. Sometimes the signal gets messed up in transit, and
that is where error checking comes in. But more on that in a later tutorial.)

By the way, people don't usually talk about switches and switch groups
when talking about computers, because it is more usual to think in terms
of information than in terms of hardware. One switch can store one "bit"
of information. So, one 0-1 unit is called a "bit". 8 bits is called a
"byte". It is called a "byte" because someone thought that "byte"
was a cute name for a bunch of "bits".

The ASCII table above has an entry for the binary "number", the equivalent
decimal number, and the character that the code is representing. There
is also a column entitled "hex", for hexidecimal. Hexidecimal is base
16.

Counting in base 16 goes like this:

HEX

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

DEC

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

Why is base 16 useful? First, let's consider why no one likes to work
directly with binary numbers. The problem with using binary is obvious,
the numbers can be very long and hard to work with. Decimal is what we
are all familiar with, and that is best EXCEPT it is a pain to convert
between binary and decimal. Try converting the following to decimal.

001100101101001001101011101010111000110

Quick! What's the answer?

I'm sorry that is incorrect. Please check your answer. And try to be
more careful.

Oh really? My mistake.

OK, how about converting this to binary?

345,663

Yes, I agree, let's just forget about that one.

But converting back and forth between hex and binary is a breeze, and
it is even more compact than decimal. The reason hex is so easy is that
4 bits gives you 16 possible combinations, and hex has exactly 16 different
digits (just as decimal has exactly 10 different digits: 0,1,2,3,4,5,6,7,8,
and 9). That means hex "lines up" with the bits - you have one hex digit
for every 4 bits. All you have to do is memorize converting binary-to-hex
from 1 to 16, and then you can easily convert arbitrarily long binary
numbers. Like this:

bin = 0001 0010 1111 1100 1010 0110 0010 1111
hex = 124FCA52F

BIN

0001

0010

0100

1111

1100

1010

0110

0010

1111

HEX

1

2

4

F

C

A

6

2

F

For this reason, programmers usually use hex when they are working directly
with binary values.

But, IP addresses (the numbers that TCP-IP uses to identify a computer)
are in decimal form for some reason, even though one frequently has to
convert back and forth between binary and decimal values. It would have
been a lot simpler if they had been in hex...