Navigation links:

Everything is a Number

In computers everything is represented as a number.

Characters are Numbers

A number is associated with each character you see on a computer display. The binding between characters and numbers is called a `character code set'. Since `character code set' is a mouthful it more common to see the phrase shortened to either `character set' or `code set'.

For a variety of reasons, there are many different character sets in existence. One of the earliest and most successful character sets is ASCII -- the American Standard Code for Information Interchange. (The ASCII acronym is pronounced as `AS-key'.) The ASCII code set provides a character to number binding for 128 characters that includes:

A portion of the ASCII character set is shown below: While for ASCII it is quite easy to just list all 128 character to number bindings in a simple column, the resulting column is relatively long and difficult to read. Character sets can be represented more compactly as a table, providing you know how to read the table. As an example, please look at the ASCII character set table below and the table explanation that follows it:
								
+--------+--------------------------------------------------+
| First  |	             Last Digit			    |
| Digits |  0    1    2    3    4    5    6    7    8    9  |
+--------+--------------------------------------------------+
|    x   | NUL  SOH  STX  ETX  EOT  ENQ  ACK  BEL  BS   HT  |
|   1x   | LF   VT   NP   CR   SO   SI   DLE  DC1  DC2  DC3 |
|   2x   | DC4  NAK  SYN  ETB  CAN  EM   SUB  ESC  FS   GS  |
|   3x   | RS   US   ` '  `!'  `"'  `#'  `$'  `%'  `&'  `'' |
|   4x   | `('  `)'  `*'  `+'  `,'  `-'  `.'  `/'  `0'  `1' |
|   5x   | `2'  `3'  `4'  `5'  `6'  `7'  `8'  `9'  `:'  `;' |
|   6x   | `<'  `='  `>'  `?'  `@'  `A'  `B'  `C'  `D'  `E' |
|   7x   | `F'  `G'  `H'  `I'  `H'  `K'  `L'  `M'  `N'  `O' |
|   8x   | `P'  `Q'  `R'  `S'  `T'  `U'  `V'  `W'  `X'  `Y' |
|   9x   | `Z'  `['  `\'  `]'  `^'  `_'  ``'  `a'  `b'  `c' |
|  10x   | `d'  `e'  `f'  `g'  `h'  `i'  `j'  `k'  `l'  `m' |
|  11x   | `n'  `o'  `p'  `q'  `r'  `s'  `t'  `u'  `v'  `w' |
|  12x   | `x'  `y'  `z'  `{'  `|'  `}'  `~'  DEL           |
+--------+--------------------------------------------------+
								
In the table above, all of the characters in a given row start with the one or two digits under the `First Digits' heading and all of the characters in a given column end with the digit under the `Last Digit' heading. For example, the capital letters `F', `G', and `H' are bound to the numbers 70, 71, and 72, respectively, since the all occur in the seven row and under the zero, one, and two columns. Similarly, the letters `P', `Z', `d', `n', and `x' are bound to the numbers 80, 90, 100, 110, and 120, respectively. Please, do not bother to memorize this table, it is shown for reference purpoese only.

ASCII has 33 non-printing characters (0 through 31, and 127), called control characters. Each control characters is given a two or three letter abbreviation. A few of the more commonly used control characters are:

While these control characters are used, their usage is not central to the discussion of characters sets; hence, control characters are not discussed any further here.

While ASCII is one of the earliest and most successful character sets, there are other character sets that provide even more character to number bindings. The newer ISO-xyx (International Standards Organization) character set is particularly popular in Europe since it has bindings for all special characters that are used by European languages. The ISO-xyz character binding is also known as Latin-1. Their are yet other character to number bindings for Asiatic languages. What is in common with all of these other character bindings is that they all represent a character as a number inside of the computer.

One other interesting characteristic of computer scientists is that they usually start with the number zero rather than one. Thus, while ASCII has 128 characters, they are numbered from 0 to 127 rather than from 1 to 128. While there are good technical reasons for always starting with the number zero, for now it can be treated as a harmless peculiarity of computer scientists.

Now that you know more about character sets, it is worth knowing how computers use them. The primary purpose of character sets is to represent text. Basically each and every character of a textual document is converted into a number using a character set. The resulting sequence of numbers is then manipulated by the computer before being eventually displayed back to you. For example, the word `Hi there!' is converted to the numbers 72, 105, 32, 116, 101, 114, 101, and 33, respectively. When these five numbers are sent to another computer, it can decode the numbers back into `Hi there!'. As another example, all of the text you are reading now is represented internally in the computer as a long sequnce of thousands of numbers. All telegrams, electronic mail, and word processing programs convert their text into a sequence of numbers for processing purposes.

As a short summary, computers convert text into a sequence of numbers using a character set, such as ASCII, to do the convesion.

Pictures By the Numbers

It turns out that computers treat pictures as numbers, too. Basically, a computer divides a picture into rows and columns, where each entry in the resulting rectangular array is called a `pixel.' The word ``pixel' is a rough contraction of the words `picture element'. Each picture element, or pixel, is stored in the computer as a number. The binding between the number and the corresponding color in the picture is called a `color map'.

The simplest color map has exactly two numbers, 0 and 1, to represent two different colors (usually black and white.) A color map with only two colors is called a `monochrome color map'. (As an aside, the word `monochrome' is the result of concatonating the words `mono' (one) and `chrome' (color); hence, monochrome literally means `one color'.)

For example, the simple triangle line drawing below is represented in the colors black and white:

	*
	|\
	| \
	|  \
	*---*
								
With the monochrome color map below: the triangle is converted into an array of numbers that looks basically as follows:
	11111111
	10111111
	10011111
	10101111
	10110111
	10111011
	10000001
	11111111
								
A non-color photograph is divided into pixels that have varying amounts of black and white, called a `gray-scale color map'. An expample gray-scale color map is shown below:

A color photograph is broken into pixels where each pixel has independently varying amounts of the colors red, green, and blue. It is actually quite remarkable that the human eye can be tricked into seeing the entire color specturm by showing varying amounts of the colors red, green, and blue. Strictly speaking, each pixel in a color photograph is actually three numbers, one number for each color. However, for purposes of compactness, these three numbers are usually combined into one number. In the example color map below, the colors are represented as numbers between 0 and 999, where the 100's digit represents red ,the 10's digit represents green, and the 1's digit represents blue. A digit of 0 represents 0% of the color and a digit of 9 represents 100% of the color.

The triangle can be turned into a black (000) triangle with a yellow (099) interior on a white (999) background using the color map above:

	999 999 999 999 999 999 999 999 
	999 000 999 999 999 999 999 999 
	999 000 000 999 999 999 999 999 
	999 000 099 000 999 999 999 999 
	999 000 099 099 000 999 999 999 
	999 000 099 099 099 000 999 999 
	999 000 000 000 000 000 000 999 
	999 999 999 999 999 999 999 999 
								
While this is the most cursory of introductions to the fasinating field of computer graphics and image processing, it should reinforce the central theme of this section that computers treat everything as a bunch of numbers.

Sounds Like a Number

Given the previous two sections, it should come as no suprise that computers treat sound as a bunch of numbers, too. Sound is basically variations of pressure in the air. A computer uses a speaker (or headphones) to reproduce the pressure variations that constitute sound. A microphone is used to detect the pressure variations and feed them into the computer. Of course, the first thing that the computer does is convert the microphone signal into a sequence of numbers, where each number basically represents the air pressure at a given moment in time.

A Compact Disk player provides very high quality sound by representing the pressure variations as numbers between 0 and 65000 (approximately), where the pressure variations are examined 56000 times per second. Thus, one second of sound occupies 56000 numbers. While that is a lot of numbers, computers can easily process 56000 in a second.

The telephone system is now mostly done with computers. The phone system represents pressure variations as numbers between 0 and 255, where the pressure variations are examined 7000 times a second. Since only 7000 numbers are required for each second of sound, the resulting sound quality is significantly less than that of a Compact Disk player.

Again, while this is the most cursory of introductions to the topic of computer (digital) signal processing, but it again illustrates the primary theme of this section, that computers treat everything as numbers.

What About All Those 1's and 0's?

It is pretty hard to live in this day and age without having read an article or book that explains how computers treat everything as binary numbers consisting of a series of 1's and 0's. When a number is represented as a series of 1's and 0's it is called a binary number. In contrast to binary numbers, people use decimal numbers represented using the ten digits 0 through 9. While it is quite true that computers do use binary numbers, this fact is about as enlighting as saying that computers run on electricity; both are interesting facts, but neither fact does much to increase your knowledge of computers. What is important is that computers convert text, images, and sounds into numbers, manipulate those numbers, and then covert the resulting numbers back into text, images, and sound that are useful to you. Thus, the important fact to realize is that to a computer, everything is a number, not that the number is represented as a binary number internal to the computer.

Why do computers use binary numbers? The simple reason why binary numbers are used in computers is because it is more economical than using decimal numbers. Back before electrical computers, it was more econnomical for mechanical calculators to use decimal numbers. It is quite possible to build an electronic computer that uses decimal numbers, but it would be more expensive than one that uses binary numbers.

It is quite possible to learn an enormous amount about computers, without learning about binary numbers. Since people are more comfortable with decimal numbers, the next several sections are going to be done using decimal numbers rather than confusing things with binary numbers.

A Quick Summary

In this section you should have learned:

The topic of computer memory is discussed in the next section.

Wayne C. Gramlich

Copyright 1993 (c) Wayne C. Gramlich. All Rights Reserved.

Limited copy permission is granted. Comments, corrections, and cross references are solicited. There are currently no known cross references.