Chapter 4 Computer Codes
Chapter 4 Computer Codes
Chapter 4 Computer Codes
Codes
Learning Objectives
Computer data
Computer codes: representation of data in binary
Most commonly used computer codes
Collating sequence
A 11 0001 61 N 10 0101 45
B 11 0010 62 O 10 0110 46
C 11 0011 63 P 10 0111 47
D 11 0100 64 Q 10 1000 50
E 11 0101 65 R 10 1001 51
F 11 0110 66 S 01 0010 22
G 11 0111 67 T 01 0011 23
H 11 1000 70 U 01 0100 24
I 11 1001 71 V 01 0101 25
J 10 0001 41 W 01 0110 26
K 10 0010 42 X 01 0111 27
L 10 0011 43 Y 01 1000 30
M 10 0100 44 Z 01 1001 31
1 00 0001 01
2 00 0010 02
3 00 0011 03
4 00 0100 04
5 00 0101 05
6 00 0110 06
7 00 0111 07
8 00 1000 10
9 00 1001 11
0 00 1010 12
Example
Show the binary digits used to record the word BASE in BCD
Solution:
B = 110010 in BCD binary notation
A = 110001 in BCD binary notation
S = 010010 in BCD binary notation
E = 110101 in BCD binary notation
Example
Using octal notation, show BCD coding for the word DIGIT
Solution:
D = 64 in BCD octal notation
I = 71 in BCD octal notation
G = 67 in BCD octal notation
I = 71 in BCD octal notation
T = 23 in BCD octal notation
A 1100 0001 C1
N 1101 0101 D5
B 1100 0010 C2
O 1101 0110 D6
C 1100 0011 C3
P 1101 0111 D7
D 1100 0100 C4
Q 1101 1000 D8
E 1100 0101 C5
R 1101 1001 D9
F 1100 0110 C6 S 1110 0010 E2
G 1100 0111 C7 T 1110 0011 E3
H 1100 1000 C8 U 1110 0100 E4
I 1100 1001 C9 V 1110 0101 E5
J 1101 0001 D1 W 1110 0110 E6
K 1101 0010 D2 X 1110 0111 E7
L 1101 0011 D3 Y 1110 1000 E8
Z 1110 1001 E9
M 1101 0100 D4
0 1111 0000 F0
1 1111 0001 F1
2 1111 0010 F2
3 1111 0011 F3
4 1111 0100 F4
5 1111 0101 F5
6 1111 0110 F6
7 1111 0111 F7
8 1111 1000 F8
9 1111 1001 F9
Example
Using binary notation, write EBCDIC coding for the word BIT.
Solution:
B = 1100 0010 in EBCDIC binary notation
I = 1100 1001 in EBCDIC binary notation
T = 1110 0011 in EBCDIC binary notation
0 0011 0000 30
1 0011 0001 31
2 0011 0010 32
3 0011 0011 33
4 0011 0100 34
5 0011 0101 35
6 0011 0110 36
7 0011 0111 37
8 0011 1000 38
9 0011 1001 39
A 0100 0001 41
B 0100 0010 42
C 0100 0011 43
D 0100 0100 44
E 0100 0101 45
F 0100 0110 46
G 0100 0111 47
H 0100 1000 48
I 0100 1001 49
J 0100 1010 4A
K 0100 1011 4B
L 0100 1100 4C
M 0100 1101 4D
N 0100 1110 4E
O 0100 1111 4F
P 0101 0000 50
Q 0101 0001 51
R 0101 0010 52
S 0101 0011 53
T 0101 0100 54
U 0101 0101 55
V 0101 0110 56
W 0101 0111 57
X 0101 1000 58
Y 0101 1001 59
Z 0101 1010 5A
Example
Write binary coding for the word BOY in ASCII-7. How many bytes are required
for this representation?
Solution:
Since each character in ASCII-7 requires one byte for its representation and
there are 3 characters in the word BOY, 3 bytes will be required for this
representation
Example
Write binary coding for the word SKY in ASCII-8. How many bytes are
required for this representation?
Solution:
Since each character in ASCII-8 requires one byte for its representation and
there are 3 characters in the word SKY, 3 bytes will be required for this
representation
Why Unicode:
No single encoding system supports all languages
Different encoding systems conflict
Unicode features:
Provides a consistent way of encoding
multilingual plain text
Defines codes for characters used in all
major languages of the world
Defines codes for special characters,
mathematical symbols, technical symbols, and
diacritics
Example
Solution:
A1 < 1A < 23
Example
Solution:
Therefore, the sorted sequence will be: 1A, 23, 2a, A1, Aa, a2, and
aA
Alphabetic data
Alphanumeric data
American Standard Code for Information Interchange (ASCII)
Binary Coded Decimal (BCD) code
Byte
Collating sequence
Computer codes
Control characters
Extended Binary-Coded Decimal Interchange Code (EBCDIC)
Hexadecimal equivalent
Numeric data
Octal equivalent
Packed decimal numbers
Unicode
Zoned decimal numbers