Title: Text Representation within Computers
1Text Representationwithin Computers
2The Binary Digit (Bit)
- One bit can encode a value set that contains two
elements - e.g. black, white, up, down, registered, not
registered, etc. - What if we need to encode a value set that
contains three values? - e.g. red, yellow, green for a traffic signal
- Can use a string of two bits
- 00 red
- 01 yellow
- 11 green
3Binary Bit Strings
2
4
8
16
Each additional bit doubles the number of
possible combinations
4The ASCII Code
- When you type text characters at your keyboard,
each character is stored as a separate bit code. - A standard bit code was assigned to each possible
character that can appear in text. - The code is called the ASCII (American Standard
Code for Information Interchange) code.
5The ASCII Code
- Original ASCII was a 7bit code
- ANSI identified a standard set of 128 characters
(including letters, digits, symbols and special
control characters) - 7 bits can provide 128 distinct bit patterns
(codes) - Extended ASCII is an 8-bit code
- Additional 128 codes are used to accommodate
letters from other languages (Arabic, French,
German, etc)
67-Bit ASCII Code Table
Rightmost Leftmost Three Bits Four
Bits 000 001 010 011 100 101 110 111 0000 NUL DL
E Space 0 _at_ P p 0001 SOH DC1 ! 1 A Q a q 0010
STX DC2 " 2 B R b r 0011 ETX DC3 3 C S c s 0100
EOT DC4 4 D T d t 0101 ENQ NAK 5 E U e u 01
10 ACK SYN 6 F V f v 0111 BEL ETB ' 7 G W g w
1000 BS CAN ( 8 H X h x 1001 HT EM ) 9 I Y i y 1
010 LF SUB J Z j z 1011 VT ESC K k 1
100 FF FS , lt L \ l 1101 CR GS - M m
1110 SO RS . gt N n 1111 SI US / ? O _ o DEL
7Using the ASCII Code Table
- Find a character in the chart
- Use the 3 bits at the top of the column the
character is in, as the first 3 bits - Use the 4 bits in at the far left side of the row
that the character is in, as the last 4 bits - This creates a binary 7-bit ASCII code
- NOTE a leading zero is added when the code is
stored in one byte
8Finding ASCII values for Characters using the
Table
- Example 1 Find the binary ASCII and decimal
ASCII values for the character.
Rightmost Leftmost Three Bits Four
Bits 000 001 010 011 100 101 110 111 0000 NUL DL
E Space 0 _at_ P p 0001 SOH DC1 ! 1 A Q a q 0010
STX DC2 " 2 B R b r 0011 ETX DC3 3 C S c s 0100
EOT DC4 4 D T d t 0101 ENQ NAK 5 E U e u 01
10 ACK SYN 6 F V f v 0111 BEL ETB ' 7 G W g w
1000 BS CAN ( 8 H X h x 1001 HT EM ) 9 I Y i y 1
010 LF SUB J Z j z 1011 VT ESC K k 1
100 FF FS , lt L \ l 1101 CR GS - M m
1110 SO RS . gt N n 1111 SI US / ? O _ o DEL
9Finding ASCII values for Characters using the
Table
- From the chart
0100110 (binary ASCII value) - Convert the binary value to decimal 01001102
32 4 2 3810 - Therefore 3810 (decimal ASCII value)
10Finding ASCII values for Characters using the
Table
- Example 2 Find the binary , octal, and hex ASCII
values for the M character.
Rightmost Leftmost Three Bits Four
Bits 000 001 010 011 100 101 110 111 0000 NUL DL
E Space 0 _at_ P p 0001 SOH DC1 ! 1 A Q a q 0010
STX DC2 " 2 B R b r 0011 ETX DC3 3 C S c s 0100
EOT DC4 4 D T d t 0101 ENQ NAK 5 E U e u 01
10 ACK SYN 6 F V f v 0111 BEL ETB ' 7 G W g w
1000 BS CAN ( 8 H X h x 1001 HT EM ) 9 I Y i y 1
010 LF SUB J Z j z 1011 VT ESC K k 1
100 FF FS , lt L \ l 1101 CR GS - M m
1110 SO RS . gt N n 1111 SI US / ? O _ o DEL
11Finding ASCII values for Characters using the
Table
- From the chart M
1001101 (binary ASCII value) - Convert the binary value to octal (re-group by
3s) 001 001 1012 1158 (octal ASCII value) - Convert the binary value to hexadecimal (by
4s) 0100 11012 4D16 (hex ASCII value)
12Finding Characters represented using the Table
- Example 3 What does the following binary ASCII
code represent? - 1001111 1001011
13Finding Characters represented using the Table
- Example Find 1001111 and 1001011 in the table
Rightmost Leftmost Three Bits Four
Bits 000 001 010 011 100 101 110 111 0000 NUL DL
E Space 0 _at_ P p 0001 SOH DC1 ! 1 A Q a q 0010
STX DC2 " 2 B R b r 0011 ETX DC3 3 C S c s 0100
EOT DC4 4 D T d t 0101 ENQ NAK 5 E U e u 01
10 ACK SYN 6 F V f v 0111 BEL ETB ' 7 G W g w
1000 BS CAN ( 8 H X h x 1001 HT EM ) 9 I Y i y 1
010 LF SUB J Z j z 1011 VT ESC K k 1
100 FF FS , lt L \ l 1101 CR GS - M m
1110 SO RS . gt N n 1111 SI US / ? O _ o DEL
14Finding Characters represented using the Table
- From the table
- 1001111 O
- 1001011 K
- So 1001111 1001011 represents OK in binary ASCII
15Character Representation ASCII Table
- Example 4 What character is represented by the
decimal ASCII value 88? - Convert the decimal value to binary 8810
64 16 8 10110002 (binary ASCII
value) - From the chart 101 1000 X
- Therefore 88 X (decimal ASCII value)
16Decimal ASCII Example
H i , H e a t h e r .
72 105 44 32 72 101 97 116 104
101 114 46
17Try It Yourself Text Representation
- How would the text So? be
represented in binary ASCII? - How would the SAME text be represented in decimal
ASCII? - What text does the following binary ASCII
represent? 10010002 11010012 - How would you represent the SAME text in octal
ASCII? - (Answers on NEXT slide)
18Answers
- So? 10100112 11011112 01111112
- In decimal ASCII 8310 11110 6310
- 10010002 11010012 represents text Hi
- The same text in octal ASCII is 1108 1518