Code_ The Hidden Language of Computer Hardware and Software - Charles Petzold [30]
000 = ***
001 = *½
010 = **½
011 = ****
101 = ***½
110 = **
111 = BOMB
This code is just as legitimate as the preceding code so long as everybody knows what it means.
If Maltin ever encountered a movie undeserving of even a single full star, he could award a half star. He would certainly have enough codes for the half-star option. The codes could be redefined like so:
000 = MAJOR BOMB
001 = BOMB
010 = *½
011 = **
100 = **½
101 = ***
110 = ***½
111 = ****
But if he then encountered a movie not even worthy of a half star and decided to award no stars (ATOMIC BOMB?), he'd need another bit. No more 3-bit codes are available.
The magazine Entertainment Weekly gives grades, not only for movies but for television shows, CDs, books, CD-ROMs, Web sites, and much else. The grades range from A+ straight down to F (although it seems that only Pauly Shore movies are worthy of that honor). If you count them, you see 13 possible grades. We would need 4 bits to represent these grades:
0000 = F
0001 = D–
0010 = D
0011 = D+
0100 = C–
0101 = C
0110 = C+
0111 = B–
1000 = B
1001 = B+
1010 = A–
1011 = A
1100 = A+
We have three unused codes: 1101, 1110, and 1111, for a grand total of 16.
Whenever we talk about bits, we often talk about a certain number of bits. The more bits we have, the greater the number of different possibilities we can convey.
It's the same situation with decimal numbers, of course. For example, how many telephone area codes are there? The area code is three decimal digits long, and if all of them are used (which they aren't, but we'll ignore that), there are 103, or 1000, codes, ranging from 000 through 999. How many 7-digit phone numbers are possible within the 212 area code? That's 107, or 10,000,000. How many phone numbers can you have with a 212 area code and a 260 prefix? That's 104, or 10,000.
Similarly, in binary the number of possible codes is always equal to 2 to the power of the number of bits:
Number of Bits
Number of Codes
1
2 1 = 2
2
2 2 = 4
3
2 3 = 8
4
2 4 = 16
5
2 5 = 32
6
2 6 = 64
7
2 7 = 128
8
2 8 = 256
9
2 9 = 512
10
2 10 = 1024
Every additional bit doubles the number of codes.
If you know how many codes you need, how can you calculate how many bits you need? In other words, how do you go backward in the preceding table?
The method you use is something called the base two logarithm. The logarithm is the opposite of the power. We know that 2 to the 7th power equals 128. The base two logarithm of 128 equals 7. To use more mathematical notation, this statement
27 = 128
is equivalent to this statement:
log2 128 = 7
So if the base two logarithm of 128 is 7, and the base two logarithm of 256 is 8, then what's the base two logarithm of 200? It's actually about 7.64, but we really don't have to know that. If we needed to represent 200 different things with bits, we'd need 8 bits.
Bits are often hidden from casual observation deep within our electronic appliances. We can't see the bits encoded in our compact discs or in our digital watches or inside our computers. But sometimes the bits are in clear view.
Here's one example. If you own a camera that uses 35-millimeter film, take a look at a roll of film. Hold it this way:
You'll see a checkerboard-like grid of silver and black squares that I've numbered 1 through 12 in the diagram. This is called DX-encoding. These 12 squares are actually 12 bits. A silver square means a 1 bit and a black square means a 0 bit. Square 1 and square 7 are always silver (1).
What do the bits mean? You might be aware that some films are more sensitive to light than others. This sensitivity to