Everything—that is to say, everything—on a computer is eventually, at the lowest level, turned into zeros and ones. Every web page, every mp3, every image, every movie, every keystroke, every video game—at the end, it’s all just zeros and ones. Sometimes the path from those zeros and ones (bits, in computer terminology) to the final product is a long and circuitous path, but other times it’s a fairly simple one.
Because everything ends up as zeros and ones, people who deal with bits on a regular basis needed an easy way to represent very long sequences of those zeros and ones. For example,
0100100001100101011011000110110001101111
is a more than a little cumbersome. If you had to copy down that sequence of bits onto a piece of paper, you might have to check several times to make sure you’d copied it accurately.
The first thing we tend to do to make things easier is to put spaces in between groups of four (much like people put commas every third digit to make 1,000,000 easier to read).
0100 1000 0110 0101 0110 1100 0110 1100 0110 1111
Already that’s a great deal easier to take in at a glance. Now, there are only a limited number of four-bit patterns. For instance, the pattern “0110” appears several times in the above seequence. So we’ve developed a set of symbols, where each symbol represents an entire four-bit pattern. For example, we could have some funky symbol like µ stand for “0110”, and a different funky symbol for “0101”, etc. Instead of using funky symbols, however, we instead decided (in the long tradition of using already-existing symbols to represent something completely different) to use the numbers 0 through 9 and the letters A through F. This gives us a total of sixteen symbols, which map perfectly to the sixteen possible four-bit patterns, exactly as follows:
0000 0 1000 8 0001 1 1001 9 0010 2 1010 A 0011 3 1011 B 0100 4 1100 C 0101 5 1101 D 0110 6 1110 E 0111 7 1111 F
This means that we can represent that unwieldy sequence of zeros and ones with ten simple characters:
4 8 6 5 6 C 6 C 6 F
Because there are sixteen symbols, we call this system of representing zeros and ones hexadecimal. In practice, pairs of hexadecimal numbers are usually grouped together, which makes it easier to read:
48 65 6C 6C 6F
This is much easier to read, remember, and copy than our original blob of forty zeros and ones.
Also, sometimes it can be confusing whether, when we write “48”, we’re talking about the hexadecimal numbers representing “0100 1000” or whether we’re talking about the decimal number “48”. To help eliminate this confusion, we typically prefix hexadecimal numbers with “\x” or “0x”. For example, 0x48 represents “0100 1000”, and 0x6C represents “0110 1100”.
Tomorrow I’ll talk about some of the specific ways things on your computer are reduced to zeros and ones—like this post, for instance!
Entries (RSS)