Perhaps you're wondering how you can represent anything as ones and zeros, let alone everything. Let's try a few examples.
I'm thinking of a number between zero and fifteen. You can ask me as many questions about it as you like, but I'll only answer "yes" or "no." How many questions do you think it will take to find my number?
In the worst possible case, you could get it in fourteen questions -- if I picked fifteen as my number, and you started by asking "Is it zero?" you would still get to fifteen eventually -- and as soon as I said "No" to fourteen, you'd know it HAD to be fifteen.
This approach -- start at zero and ask about each number in turn -- is called a serial search. "Serial" means one after another, or one step at a time. It's not cheating to try to improve on your results. For instance, if you know that your kid brother always picks "two" or "seven," you could use that knowledge and ask about those two numbers first -- this is called "weighting" the list, and if your data isn't truly random, a weighted serial search can be the most effective solution.
But if you're up against someone (like Mother Nature) who is smart enough to pick a truly random number, there is another search technique that is much more effective: a binary search. In fact, you can ALWAYS get the answer to our little puzzle using just four questions! Watch -- I just picked a new number:
Is it in the red half of the list?
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
No
Is it in the red quarter of the list?
0 1 2 3 4 5 6 7 8 9 10
11 12 13 14 15
Yes
Is it in the red eighth of the list?
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15
Yes
Is it 8?
Yes
Try this with any number between 0 and 15 and you'll find that it always works in exactly four questions.
Now imagine we're doing this with more numbers -- zero to 255. The serial search needs 254 questions to exhaust the possibilities. The binary search needs only eight questions. (Try it!) The more choices you add, the better the binary search works.
The largest number you can represent with a certain number of bits is given by 2 raised to the power 'n', minus one (because we're using one possible value to represent zero). So four bits all turned on represents fifteen, which is two to the fourth, or sixteen, minus one. Five "on" bits would be thirty-one, six bits would be sixty-three, and seven bits would be one hundred twenty-seven.
You tell a web browser to make a color by specifying a number between zero (black) and 255 (full brightness). When you're dealing with computers, it is sometimes easier to use a base-sixteen number system. What does that mean? We use sixteen digits: 0 1 2 3 4 5 6 7 8 9 a b c d e f. Instead of carrying to the "tens" place, we carry to the "sixteens" place. The "hex" number "f" stands for fifteen, and fifteen in the sixteens place is 240 (because 15 x 16 = 240). 240 + 15 = 255. So "ff" = 255 in decimal.
Web browser colors are specified by giving three two-digit hexadecimal
numbers. The colors are specified in order: red, green, blue. To make
red dots, we give the first two-digit hex number a big value, and leave
the other two numbers zero, like so:
<font color="#ff0000">
This is the same as saying red is maximum, or 255; green is off (or zero)
and blue is also off, zero.
A bright blue would look like this:
<font color="#0000ff">
If you prefer a dark blue, it would look like this:
<font color="#00007f">
The number 7f is half of ff, because 7 x 16 = 112, and 112 + 15 = 127. So this makes the value for the blue dots only half as bright.