How are
characters stored?
We
already know the answer, because we know:
1. Characters are symbols and the
computer does NOT work with symbols
2. The computer ONLY works with numeric values
3. The basic unit of storage is a byte (8-bits)
4. Characters are stored on 8-bits according to the ASCII coding scheme
If we look at the ASCII tables, the
Decimal, Octal, Hex, and Binary values for each ASCII character are all given:
Decimal |
Octal |
Hexadecimal |
Binary |
Symbol |
Meaning |
0 |
0 |
0 |
00000000 |
NUL |
The NULL Character |
1 |
1 |
1 |
00000001 |
SOH |
start-of-heading |
2 |
2 |
2 |
00000010 |
STX |
start-of-text |
º º º |
º º º |
º º º |
º º º |
º º º |
º º º |
33 |
41 |
21 |
00100001 |
! |
Exclamation Mark |
34 |
42 |
22 |
00100010 |
" |
Double
Quotation |
35 |
43 |
23 |
00100011 |
# |
Number
Sign |
º º º |
º º º |
º º º |
º º º |
º º º |
º º º |
48 |
60 |
30 |
00110000 |
0 |
The Character 0 |
49 |
61 |
31 |
00110001 |
1 |
The Character 1 |
50 |
62 |
32 |
00110010 |
2 |
The Character 2 |
51 |
63 |
33 |
00110011 |
3 |
The Character 3 |
52 |
64 |
34 |
00110100 |
4 |
The Character 4 |
º º º |
º º º |
º º º |
º º º |
º º º |
º º º |
65 |
101 |
41 |
01000001 |
A |
Capital
A |
66 |
102 |
42 |
01000010 |
B |
Capital
B |
º º º |
º º º |
º º º |
º º º |
º º º |
º º º |
* * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * *
Reminder:
For the
first test, you MUST memorize (there is no other way of
doing this) the corresponding decimal values for the ASCII characters:
-
NUL
(i.e., decimal 0)
-
BEL
(i.e., decimal 7)
-
Backspace (BS; i.e., decimal 8)
-
Carriage Return (CR; i.e., decimal 13)
-
Escape
(ESC; i.e., decimal 27)
-
Space
(SP; i.e., decimal 32)
-
The
digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 (i.e., '0' = decimal 48;
'1' = decimal 49; '2' = decimal 50 and so forth)
-
The
Upper case alphabet: A ,,, Z (i.e., 'A' = decimal 65; 'B' =
decimal 66; 'C' = decimal 67 and so forth)
-
The
Lower case alphabet: a ... z (i.e., 'a' = decimal 97; 'b' =
decimal 98; 'c' = decimal 99 and so forth)
* * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * *
For
example, the character 'H' (Uppercase 'H') is stored as the integer 72
on 8-bits (1-byte):
Notice
that since we have 8-bits to work with, we have 28 = 256
combinations, meaning we can represent, for example, all of the integers from 0
to 255.
Wait, Wait !!! That's not very many
!!! How can we store larger integers ??
Just as we saw earlier, we
need to add more bits.
.How
many ???
Depends. We'll talk about
that in the next tutorial.
Some good references to help
you better understand Characters
include:
ASCII: From Wikipedia
What
is ASCII?
An explanation of
ASCII
Some
questions you should be able to answer:
1. Which of the following statements
are false?
a. Characters are
symbols and the computer works with symbols
b. The computer ONLY works with numeric values
c. The basic unit of storage is a byte (8-bits)
d. Characters are stored on 8-bits according to the ASCII coding scheme
e. Given 8-bits, we can store 256 characters
Answer: A
2. Show how the character 'k'
(lower case 'k') would be stored
This page was last updated on
05/28/05