ASCII

American Standard Code for Information Interchange

ASCII is also an 8 bit code but it is used to represent data on PC's. All computers represent data internally with 1's and 0's. The PC industry decided to use a different coding scheme for their data, and that is where ASCII comes in. There are no zones and digits in ASCII as there were in EBCDIC, there are only 8 continuous bits. Again we use the binary number line, this time the line starts with one on the far right side and continues to 128. Example:

128 64 32 16 8 4 2 1

To represent numbers in ASCII, the first four bits are always, always, 0011. The last four bits are used to represent the number you are trying to convert. Example.

128 64 32 16 8 4 2 1

0 0 1 1 1 0 1 0 would be the ASCII equivalent for the number 10. Notice the first four bits are 0011, then the last four add up to 10, the number we converted. Another example:

128 64 32 16 8 4 2 1

0 0 1 1 0 1 1 0 - would be the ASCII for the number 6. Again the first four bits are 0011, then the last four add up to 6.

If you have a two digit or larger number, you would have had to hit at least two keys on the keyboard to enter the number, so you divide the number into single digits and convert each digit to ASCII. Example:

128 64 32 16 8 4 2 1 128 64 32 16 8 4 2 1

0 0 1 1 1 0 0 1 0 0 1 1 0 0 1 0 - would be the ASCII for the number 92.

 

Letters of the alphabet are represented in ASCII by placing a 1 in the 64 position of the number line and a 0 in the 128 and 32 position of the number line. The remaining numbers in the number line are used to add up to the number that corresponds to the letters placement in the alphabet. Example:

A is the first letter of the alphabet, so the ASCII for A would be:

128 64 32 16 8 4 2 1

0 1 0 0 0 0 0 1

Notice that the first three bits are 010, for letters of the alphabet, they will always be 010. The last 5 bits are then used to express the letters placement in the alphabet. Since A is the first letter in the alphabet, we only put a 1 under the 1 in the number line, all the other's are 0's. Another example:

Q is the 17th letter of the alphabet, so the ASCII for Q would be:

128 64 32 16 8 4 2 1

0 1 0 1 0 0 0 1

Again, the first three bits are 010, then the last five bits represent the number 17, 16+1=17.