Computer Coding System
Computer Coding System
1|P a g e
ShrutiKhatri
10
101
11
100
110
111
1000
16 - (10)
1001
1010
1011
1100
1101
1110
1111
10000
Since binary is a base-2 system, each digit represents an increasing power of 2, with the
rightmost digit representing 20, the next representing 21, then 22, and so on. To determine the
decimal representation of a binary number simply take the sum of the products of the binary
digits and the powers of 2 which they represent. For example, the binary number:
2|P a g e
ShrutiKhatri
0000
0000
0001
0001
0010
0011
0011
0010
0100
0110
B. the most significant bit of the binary number is the most significant bit 5
of the gray code.
6
0101
0111
0110
0101
0111
0100
1000
1100
1001
1101
10
1010
1111
11
1011
1110
12
1100
1010
13
1101
1011
14
1110
1001
15
1111
1000
C. add (using modulo 2) the next significant bit of the binary number to
the next significant bit of the gray coded number to obtain the next binary
bit
D. repeat step C till all bits of the gray coded number have been added
modulo
2
the resultant number is the binary equivalent of the gray number
3|P a g e
ShrutiKhatri
Answer: 1
Step 2) Add from left to right bit by bit of your binary number:
Answer: 10
Step 3) Continue:
1(1+0)01010
Answer: 101
------------------------11(0+0)1010
Answer: 1010
-----------------------110(0+1)010
Answer: 10101
110010(1+0)
Answer: 10101111 <- Answer in Gray Code.
Gray code is where only one bit changes at a time. Binary code is where one or more bits change
at a time. An example, for three bits, with binary on the left and gray on the right, with the
changing bits underlined...
000
000
001 001
010 011
011 010
4|P a g e
ShrutiKhatri
100 110
101 111
110 101
111 100
000 000 Repeating...
The advantage of binary code is that it is easy to convert to a numeric value. The advantage of
gray code is that it makes very stable position digitizers, because only one bit changes at a time,
resulting in uncertainty of only one bit.
When you look at figure 4-3, you will notice that the four rightmost bits in EBCDIC are assigned
values of 8, 4, 2, and 1. The next four bits to the left are called the zone bits. The EBCDIC
coding chart for uppercase and lowercase alphabetic characters and for the numeric digits 0
through 9 is shown in figure 4-4, with their hexadecimal equivalents. Hexadecimal is a number
system used with some computer systems. It has a base of 16 (0-9 and A-F). A represents 10; B
represents 11; C represents 12; D represents 13; E represents 14; and F represents 15. In
EBCDIC, the bit pattern 1100 is the zone combination used for the alphabetic characters A
through I, 1101 is used for the characters J through R, and 1110 is the zone combination used for
characters S through Z. The bit pattern 1111 is the zone combination used when representing
decimal digits. For example, the code 11000001 is equivalent to the letter A; the code 11110001
is equivalent to the decimal digit 1. Other zone combinations are used when forming special
characters. Not all of the 256 combinations of 8-bit code have been assigned characters. Figure
4-5 illustrates how the characters DP-3 are represented using EBCDIC.
Figure . - Eight-bit EBCDIC coding chart (including exadecimal equivalents).
5|P a g e
ShrutiKhatri
92
73
EBCDIC
10010010 01110011
BYTE1 BYTE2
6|P a g e
ShrutiKhatri
In ASCII, rather than breaking letters into three groups, uppercase letters are assigned codes
beginning with hexadecimal value 41 and continuing sequentially through hexadecimal
value 5A. Similarly, lowercase letters are assigned hexadecimal values of 61 through 7A.
The decimal values 1 through 9 are assigned the zone code 0011 in ASCII rather that 1111 as in
EBCDIC. Figure is the ASCII coding chart showing uppercase and lowercase alphabetic
characters and numeric digits 0 through 9.
Figure - Eight-bit ASCII coding chart (including hexadecimal equivalents).
7|P a g e
ShrutiKhatri
At this point you should understand how coding systems are used to represent data in both
EBCDIC and ASCII. Regardless of what coding system is used, each character will have an
additional bit called a check bit or parity bit.
PARITY BIT
This additional check or parity bit in each storage location is used to detect errors in the circuitry.
Therefore, a computer that uses an 8-bit code, such as EBCDIC or ASCII, will have a ninth bit
for parity checking.
The parity bit (also called a check bit, the C position in a code) provides an internal means for
checking the validity, the correctness, of code construction. That is, the total number of bits in a
character, including the parity bit, must always be odd or always be even, depending upon
whether the particular computer system or device you are using is odd or even parity. Therefore,
the coding is said to be in either odd or even parity code, and the test for bit count is called
a parity check.
8|P a g e