Sie sind auf Seite 1von 11

Sirifort College of Computer Technology and Management

(Affiliated to G.G.S.I.P. University)

GENERAL PROFICIENCY
SUBMITTED TO: SUBMITTED BY:
MS.DEEPTI GOEL PRASHANT RUSTAGI
(ASST. PROF. BCA DEPT.) ENROLMENT NO - 01524302016
MS.RUPALI PANDEY (BCA 1ST YEAR) (EVENING SHIFT)
(ASST. PROF. BCA DEPT.)
BCD , GRAY CODE & EXCESS-
3 CODE
BCD (BINARY CODED DECIMAL)
Decimal BCD

• It is a class of binary encodings 0


digit

0
8
0
4
0
2
0
1

of decimal numbers where each 1 0 0 0 1

decimal digit is represented by 2 0 0 1 0


3 0 0 1 1
a fixed number of bits, usually 4 0 1 0 0

four or eight. Special bit 5 0 1 0 1


6 0 1 1 0
patterns are sometimes used for 7 0 1 1 1

a sign or for other indications. 8 1 0 0 0


9 1 0 0 1
UNPACKED BCD
• Each numeral is encoded into one byte, with four bits
representing the numeral and the remaining bits having no
significance.

Decimal: 9 1
Binary : 0000 1001 0000 0001
PACKED BCD
• Two numerals are encoded into a single byte, with one
numeral in the least significant nibble (bits 0 through 3)
and the other numeral in the most significant nibble (bits 4
through 7).
Decimal: 9 1
Binary : 1001 0001
DIFFERENCE B/W BINARY & BCD
After 9 the decimal equivalent binary number is of four bit but in case of
BCD it is an eight bit number. For 0 to 9 decimal numbers both binary and
BCD is equal but when decimal number is more than 9 BCD differs from
binary.
Binary Coded
Decimal number Binary number
Decimal(BCD)
8 1000 1000
9 1001 1001
10 1010 0001 0000
11 1011 0001 0001
12 1100 0001 0010
GRAY CODE
Decimal Gray code

• A Gray code is an encoding of numbers so that 0 0000


adjacent numbers have a single digit differing 1 0001
by 1. The term Gray code is often used to refer
2 0011
to a "reflected" code, or more specifically
3 0010
known as reflected binary code (RBC).
4 0110

5 0111
CONVERSION BINARY TO GRAY
• The MSB of the Gray code is same
as the corresponding bit in the
binary number.
• Going from left to right , add each
adjacent pair of binary bit to get
next gray code bit and discard
carry.
CONVERSION GRAY TO BINARY

• The MSb in the binary code is same


as the corresponding bit in the
gray code.
• Add each binary digit generated
to the gray digit in the next
adjacent position and discard
carry.
EXCESS-3 CODE

• Also called XS3, is a non-weighted Decimal Binary Excess-3

code used to express decimal


0 0000 0011
numbers. It is another important
binary code. It is particularly 1 0001 0100
significant for arithmetic operations as
it overcomes the shortcomings 2 0010 0101
encountered while using the 8421
BCD code to add two decimal digits 3 0011 0110

whose sum exceeds 9.


OBTAINING EXCESS-3 CODE
• The Excess-3 code for a given decimal number is determined by adding '3' to
each decimal digit in the given number and then replacing each digit of the
newly found decimal number by its four bit binary equivalent.
• We can add 0011 to a BCD code and get its Excess-3 equivalent.
For example, XS3 code of 24 is obtained as
2 4
+3 +3
5 7
0101 0111

Das könnte Ihnen auch gefallen