You are on page 1of 7

BINARY CODES FOR DECIMAL DIGITS

Binary codes are used to represent distinctly


all members among a group of quantities.
Generally, if there are n quantities in a group, a
code of b binary digits or bits may represent all
quantities uniquely.
n 2b
Example: 10 decimal digits (0-9) can be
represented by 4-bit binary code.

(A) WEIGHTED BINARY CODE FOR DECIMAL DIGITS


(WEIGHTED BCD)

Natural BCD (8421 code)


- Used whenever decimal information is transferred in or out of a
digital system.
- Straight assignment of binary equivalent is used with weights
8-4-2-1.
84-2-1 code, 2421 code
- Weighted, reflected and self-complementing codes.
- In 2421 code, if a number has more than one representation, choose
the code that uses the lower binary weights (for numbers 0 to 4 only).
5421 code
- Weighted code with weights 5-4-2-1.
- In 5421 code, if a number has more than one representation, choose
the code that uses the lower binary weights.
NOTES004 BINARY CODE FOR DECIMAL DIGITS PAGE 1
DIGITAL SYSTEM I LECTURE NOTES by Engr. Analene Montesines-Nagayo
7421 code
- Weighted code with weights 7-4-2-1.
- For decimal number 7, choose code with least number of 1s.
Biquinary code
- Weighted code with weight 5-0-4-3-2-1-0.
- A seven-bit code with error-detection properties.
- Each decimal digit consists of (5) 0s and (2) 1s placed in the
corresponding columns.
- Always use weights 5 or 0 at the left side.
5311 code
- Weighted code with weights 5-3-1-1.
- In 5311 code, if a number has more than one representation, choose
the code with least number of 1s and use first the 1 from extreme
right.
DECIMAL 5311
NUMBER
0 0000
1 0001
2 0011
3 0100
4 0101
5 1000
6 1001
7 1011
8 1100
9 1101

(B) UNWEIGHTED BINARY CODE FOR DECIMAL DIGIT


(UNWEIGHTED BCD)
Excess 3 (XS3) code
- It is obtained by adding 3 (0011 in binary) to the 8421 code.
- It is reflected, self-complementing code.
DECIMAL EXCESS 3
NUMBER CODE
0 0011
1 0100
2 0101
3 0110
4 0111
5 1000
6 1001
7 1010
8 1011
9 1100

NOTES004 BINARY CODE FOR DECIMAL DIGITS PAGE 2


DIGITAL SYSTEM I LECTURE NOTES by Engr. Analene Montesines-Nagayo
(C) GRAY CODE
- It is also known as the reflected and unit distance code.
- Reflected: mirror image
- Unit distance: exhibits only a single bit change from one code to the
next.
- It is also an unweighted and not an arithmetic code.

DECIMAL GRAY CODE


NUMBER
0 000
1 001
2 011
3 010
4 110
5 111
6 101
7 100

DECIMAL GRAY CODE


NUMBER
0 0000
1 0001
2 0011
3 0010
4 0110
5 0111
6 0101
7 0100
8 1100
9 1101
10 1111
11 1110
12 1010
13 1011
14 1001
15 1000

Binary to Gray Code Conversion


1) Place a leading zero before the MSB.
2) Compare the adjacent bit starting from the leading zero.
3) If the two compared bits are the same 0, if not 1

examples: 5 1 0 1 Binary
0 1 0 1
1 1 1 Gray Code
NOTES004 BINARY CODE FOR DECIMAL DIGITS PAGE 3
DIGITAL SYSTEM I LECTURE NOTES by Engr. Analene Montesines-Nagayo
14 1 1 1 0 Binary
0 1 1 1 0
1 0 0 1 Gray Code

Gray Code to Binary Conversion


1) Drop the MSB.
2) Compare this to the next adjacent bit.
3) If the compared bits are the same 0, if not 1

examples: 5 1 1 1 Gary Code


/ /
1 0 1 Binary

14 1 0 0 1 Gray Code
/ / /
1 1 1 0 Binary

(D) ERROR DETECTION CODE


- Used to detect error in digital circuit, especially during transmission
of bits from one location to the other.
- Systems use a parity bit as a means for bit error detection. Error
detection codes contain either an even or an odd number of 1s.
- A parity bit is an extra bit attached to a group of bits to make the
total number of 1s in a group either even or odd.

ODD PARITY number of 1s is odd


EVEN PARITY number of 1s is even

NOTES004 BINARY CODE FOR DECIMAL DIGITS PAGE 4


DIGITAL SYSTEM I LECTURE NOTES by Engr. Analene Montesines-Nagayo
(E) ALPHANUMERIC CODES
- Alphanumeric codes are codes that represent numbers and alphabetic
characters (letters). Most such codes, however, also represent other
characters such as symbols and various instructions necessary for
conveying information.

ASCII American Standard Code for Information Interchange


- It is a universally accepted alphanumeric code used in most
computers and other electronic equipment.
- ASCII has 128 characters and symbols represented by a 7-bit binary
code.
- ASCII can be considered an 8-bit code with the MSB zero or in data
communication system; the MSB is reserved for parity.
- The first thirty-two are non-graphic commands that are never printed
or displayed and used only for control purposes.
- It allows manufacturers to standardize I/O hardware such as
keyboard, printer and video display.

EBCDIC Extended Binary Coded Decimal Interchange Code


- It is an 8-bit character code developed by IBM.
- It is used in IBM equipment to represent characters and symbols.

ASCII TABLE

NOTES004 BINARY CODE FOR DECIMAL DIGITS PAGE 5


DIGITAL SYSTEM I LECTURE NOTES by Engr. Analene Montesines-Nagayo
EBCDIC TABLE

NOTES004 BINARY CODE FOR DECIMAL DIGITS PAGE 6


DIGITAL SYSTEM I LECTURE NOTES by Engr. Analene Montesines-Nagayo
DRILL PROBLEMS
I. Fill the table below.
DEC NBCD 84-2-1 2421 5421 5311 XCS-3 BIQUINARY GRAY
CODE CODE CODE CODE CODE CODE
0110

1001

0111

1111

1001000

II. Express the word COE in ASCII using even parity generator and odd parity generator.
Answer:
ASCII with even parity =____________________________________________2
ASCII with odd parity = ____________________________________________2

REFERENCES

[1] Thomas, Floyd L., Digital Fundamentals, 4th Edition, Macmillan Publishing
Company, New York, 1990
[2] Mano, M. and Kime, C., Logic and Computer Design Fundamentals, 2nd Edition,
Prentice Hall Intl., N.J., 2001
[3] Mano, M., Digital Design, 2nd Edition, Prentice Hall, N.J, 1991
[4] Hall, D., Microprocessors and Interfacing: Programming and Hardware, 2nd
Edition, Glencoe Division of Macmillan/McGraw-Hill School Publishing Company,
1992
[5] Tocci, R. and Widmer, N., Digital Systems: Principles and Applications, 8th
Edition, Prentice Hall Inc., N.J., 2001
[6] Swidlec Lecture Notes by Edzel Lapira, DLSU

NOTES004 BINARY CODE FOR DECIMAL DIGITS PAGE 7


DIGITAL SYSTEM I LECTURE NOTES by Engr. Analene Montesines-Nagayo

You might also like