Unit 11
Unit 11
• Coding a process of
is representing or non-
instructions
numeric in binary. dataand
numeric
• By coding each digit, character or
symbol is represented with group of
bits know as byte.
• e.g. 9 is represented as 1001.
CODE
SCHEME
• A binary coding scheme is a method
used for representing all of the digits,
letters, special characters, and control
characters available to a digital
computer using groups of 0s and 1s.
• The two coding schemes in widest
use are American Standard Code for
Interchange Information
(ASCII) and Extended
Coded Decimal Interchange Code Binary
CODE
SCHEME
• Here are some examples of how the
characters A, 7, and $ would be represented in
ASCII and EBCIDIC:
ASCII EBCIDIC
A 01000001 11000001
7 00110111 11110111
$ 00100100 01011011
CODE
SCHEME
• Method of coding digits, characters and
symbols into binary digits is called Code
Scheme e.g. BCD, ASCII, EBCDIC etc.
• Most commonly used code is BCD (Binary
Coded Decimal)
DIFFERENCE BETWEEN
CODING & CONVERSION
A 11 0001 61
B 11 0010 62
Z 01 1001 31
1 00 0001 01
2 00 0010 02
9 00 1001 11
BCD (continued)
N= W(i) b(i)
Where: N is the Decimal Number
W(i) are weights assigned to
Bits
b(i) are Bits, either 0 or 1
EXAMPLES OF
WEIGHTED CODES
• 8421 is a weighted code where
weights are 8,4,2,1
• Decimal number represented by 1001
is
8x1 + 4x0 + 2x0 + 1x1 = 9
__
• 8 4 2 1 where weights are 8, 4, -2, -1.
This indicates that weights can be
negative also
The code assigns the weights 2, 4, 2, and 1 to the four bits from
left to right, so the total weight is 9.
For example, the 2421 code for the decimal number 5137 is
1011 0001 0011 1101
ASCII CODES
• ASCII 8
– 8 bits are used to code each character
– First 128 characters are same as in 7 bits standard
– 256 character codes are available for printable and non-
printable characters
A 0100 0001 41
B 0100 0010 42
Z 0101 1010 5A
1 0011 0001 31
2 0011 0010 32
9 0011 1001 39
Extended ASCII
• Example
code for A is 1100 0001
code for a is 1000 0001
code for 0 is 1111 0000
EBCDIC
A 1100 0001 C1
B 1100 0010 C2
Z 1110 1001 E9
1 1111 0001 F1
2 1111 0010 F2
9 1111 1001 F9
Extend
ed
ASCII
Excess-3 (XS-3)
Code
• A self-complimenting code need
not necessarily be weighted. E.g Excess-3
• In this code, 3 is added to individual
digit before converting it to BCD.
• Excess-3 code for 42 is:
4 2
3 3
(+)
7 5
011 0101
Cyclic Code
+ + + + + +
B3 B2 B1 1 0 0 1
B0
G3 G2 G1 1 1 0 1
G0
Gray to Binary Conversion
+ + + + + +
G3 G2 G1 1 1 0 1
G0
B3 B2 B1 1 0 0 1
B0
Error Detecting &
Correcting Codes
• Binary data is transferred from one
point to another through wires or
through radio waves
• During transfer some of the bit
may change due to noise signal
(Any unwanted Signal).
• This change in bit during transfer is
called Error
Error Detecting & Correcting
Codes
• Error detecting and correcting codes are used
to detect and correct these errors
• Parity bits are used in these error
detecting and correcting codes
• The code ensures that the HAMMING
DISTANCE between any two codes in the set of
codes is a preassigned minimum
Error Detecting
Codes
• In these codes parity bits are added
horizontally as well as vertically along with
block of data, at the sending end
• ENCODING FORMATS:
• Unicode Transformation Format – 8
• UTF – 16
• UTF – 32
UNICODE @ INDIA