Code_ The Hidden Language of Computer Hardware and Software - Charles Petzold [34]
Recall the rules of Morse code: A dash is three times as long as a dot. The dots and dashes of a single letter are separated by a pause the length of a dot. Letters within a word are separated by pauses equal in length to a dash. Words are separated by pauses equal in length to two dashes.
Just to simplify this analysis a bit, let's assume that a dash is twice the length of a dot rather than three times. That means that a dot can be a 1 bit and a dash can be two 1 bits. Pauses are 0 bits.
Here's the basic table of Morse code from Chapter 2:
Here's the table converted to bits:
A
101100
J
101101101100
S
1010100
B
1101010100
K
110101100
T
1100
C
11010110100
L
1011010100
U
10101100
D
11010100
M
1101100
V
1010101100
E
100
N
110100
W
101101100
F
1010110100
O
1101101100
X
11010101100
G
110110100
P
10110110100
Y
110101101100
H
101010100
Q
110110101100
Z
11011010100
I
10100
R
10110100
Notice that all the codes begin with a 1 bit and end with a pair of 0 bits. The pair of 0 bits represents the pause between letters in the same word. The code for the space between words is another pair of 0 bits. So the Morse code for "hi there" is normally given as
but Morse code using bits can look like the cross section of the UPC code:
In terms of bits, Braille is much simpler than Morse code. Braille is a 6-bit code. Each character is represented by an array of six dots, and each of the six dots can be either raised or not raised. As I explained in Chapter 3, the dots are commonly numbered 1 through 6:
The word "code" (for example) is represented by the Braille symbols:
If a raised dot is 1 and a flat dot is 0, each of the characters in Braille can be represented by a 6-bit binary number. The four Braille symbols for the letters in the word "code" are then simply:
100100 101010 100110 100010
where the leftmost bit corresponds to the 1 position in the grid, and the rightmost bit corresponds to the 6 position.
As we shall see later in this book, bits can represent words, pictures, sounds, music, and movies as well as product codes, film speeds, movie ratings, an invasion of the British army, and the intentions of one's beloved. But most fundamentally, bits are numbers. All that needs to be done when bits represent other information is to count the number of possibilities. This determines the number of bits that are needed so that each possibility can be assigned a number.
Bits also play a part in logic, that strange blend of philosophy and mathematics for which a primary goal is to determine whether certain statements are true or false. True and false can also be 1 and 0.
Chapter 10. Logic and Switches
What is truth? Aristotle thought that logic had something to do with it. The collection of his teachings known as the Organon (which dates from the fourth century B.C.E.) is the earliest extensive writing on the subject of logic. To the ancient Greeks, logic was a means of analyzing language in the search for truth and thus was considered a form of philosophy. The basis of Aristotle's logic was the syllogism. The most famous syllogism (which isn't actually found in the works of Aristotle) is
All men are mortal;
Socrates is a man;
Hence, Socrates is mortal.
In a syllogism, two premises are assumed to be correct, and from these a conclusion is deduced.
The mortality of Socrates might seem straightforward enough, but there are many varieties of syllogisms. For example, consider the following two premises, proposed by the nineteenth-century mathematician Charles Dodgson (also known as Lewis Carroll):
All philosophers are logical;
An illogical man is always obstinate.
The conclusion isn't obvious at all. (It's "Some obstinate persons are not philosophers." Notice the unexpected and disturbing appearance of the word "some.")
For over two thousand years, mathematicians wrestled with Aristotle's logic, attempting to corral it using mathematical symbols and operators. Prior to the nineteenth century,