GAme

tiistai 26. kesäkuuta 2012

Symbols as Bits - ASCII Characters

Ok, so numbers are simply groups of bits.  What other objects will the computer's instructions manipulate?  How about the symbols that make up an alphabet?
It should come as no surprise that symbols that make up alphabets are just numbers, groups of bits, too.  But how do we know which numbers are used to represent which symbols, or characters as I'm going to call them from this point on?
It's all about standards.  In these lessons, we will use the American Standard Code for Information Interchange (ASCII) standard.  It is so ubiquious that it even has its own web page, www.asciitable.com.
Let's walk through a couple of examples, entries in the table.  Here are some characters, their decimal value and their binary value which is then transformed into an octal number.

        Uppercase 'A' = decimal 65 = binary 01000001 = 01 000 001 = octal 101
        Uppercase 'Z' = decimal 90 = binary 01011010 = 01 011 010 = octal 132
        The digit '1' = decimal 49 = binary 00110001 = 00 110 001 = octal 061
   
Table 1.4 is a small slice from the full ASCII character set, just enough to give you a flavor of its organization.
ASCII
Character
in
Binary
in
Octal
in
Decimal
in
Hex
space
00100000
040
32
20
(
00101000
050
40
28
)
00101001
051
41
29
*
00101010
052
42
2A
0
00110000
060
48
30
1
00110001
061
49
31
2
00110010
062
50
32
9
00111001
071
57
39
A
01000001
101
65
41
B
01000010
102
66
42
C
01000011
103
67
43
Z
01011010
132
90
5A
a
01100001
141
97
61
b
01100010
142
98
62
c
01100011
143
99
63
z
01111010
172
122
7A
Table 1.4

Here's a little trivia, from days long past when computers were so slow (compared with today).
  • Look closely at the binary representations of uppercase and lowercase letters.  You can convert uppercase to lowercase by turning on a single bit.  Or clearing the bit converts lowercase to uppercase.
  • Clearing two bits will convert an ASCII digit to its numeric value.  Setting the same bits converts a number in the range 0...9 into its ASCII character representation.

Ei kommentteja:

Lähetä kommentti