0% found this document useful (0 votes)
28 views14 pages

Binary Codes

The document explains Binary Coded Decimal (BCD) and its conversion methods, detailing how to convert BCD to binary and vice versa, along with the Excess-3 code. It also introduces Gray code, including conversion processes between binary and Gray code. Additionally, it outlines an assignment on alphanumeric codes and error detection and correction codes.

Uploaded by

Kofi Boateng
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views14 pages

Binary Codes

The document explains Binary Coded Decimal (BCD) and its conversion methods, detailing how to convert BCD to binary and vice versa, along with the Excess-3 code. It also introduces Gray code, including conversion processes between binary and Gray code. Additionally, it outlines an assignment on alphanumeric codes and error detection and correction codes.

Uploaded by

Kofi Boateng
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

BINARY CODES

BINARY CODED DECIMAL(BCD)


• A binary code used to represent a given decimal number in an
equivalent binary form.
• The BCD equivalent of a decimal number is written by replacing each
decimal digit in the integer and fractional parts with its four-bit binary
equivalent.
• example, the BCD equivalent of (23.15)10 is written as (0010
0011.0001 0101)BCD.
• Eg above known as the 8421 BCD code starting from MSB and
proceeding towards LSB.
CONVERSIONS
• BCD to Binary
• First: write its decimal equivalent
• Second: convert it into its binary equivalent.
Eg.
BCD number: 0010 1001.0111 0101.
• Corresponding decimal number: 29.75.
• The binary equivalent of 29.75 can be determined to be 11101 for the integer part
and .11 for the fractional part.
• Therefore, (0010 1001.0111 0101)BCD =(11101.11) 2.
• Binary to BCD
• First: determine its decimal equivalent
• Second: write the corresponding BCD equivalent
• Eg
• The decimal equivalent of this binary number can be determined to be 171.625.
• The BCD equivalent can then be written as 0001 0111 0001.0110 0010 0101.
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.
• As an example, let us find the excess-3 code for the decimal number
597:
• The addition of ‘3’ to each digit yields the three new digits/numbers ‘8’, ‘12’
and ‘10’.
• The corresponding four-bit binary equivalents are 1000, 1100 and 1010
respectively.
• The excess-3 code for 597 is therefore given by: 1000 1100
1010=100011001010.
EXAMPLES (XS-3)
• Find (a) the excess-3 equivalent of (237.75)10 and (b) the decimal
equivalent of the excess-3 number 110010100011.01110101.
• SOLUTION
• (a) Integer part=237. The excess-3 code for (237)10 is obtained by replacing 2, 3 and 7 with
the four-bit binary equivalents of 5, 6 and 10 respectively.
• This gives the excess-3 code for (237)10 as: 0101 0110 1010=010101101010
• Fractional part=.75. The excess-3 code for (.75)10 is obtained by replacing 7 and 5 with the
four-bit binary equivalents of 10 and 8 respectively.
• That is, the excess-3 code for (.75)10 =.10101000.
• Combining the results of the integral and fractional parts, the excess-3 code for (237.75)10
=010101101010.10101000.

• (b)The excess-3 code=110010100011.01110101=1100 1010 0011.0111 0101.


• Subtracting 0011 from each four-bit group, we obtain the new number as: 1001 0111
0000.0100 0010.
• Therefore, the decimal equivalent=(970.42)10.
GRAY CODE
• Designed by Frank Gray at Bell Labs and patented in 1953.
• It is an unweighted binary code in which two successive values differ
only by 1 bit.
CONVERSIONS
BINARY TO GRAY CODE CONVERSION

1. Begin with the most significant bit (MSB) of the binary number.
• The MSB of the Gray code equivalent is the same as the MSB of the given binary number.
2. The second most significant bit, adjacent to the MSB, in the Gray code number
is obtained by
adding the MSB and the second MSB of the binary number and ignoring the carry,
if any.
• That is, if the MSB and the bit adjacent to it are both ‘1’, then the corresponding Gray
code bit would be a ‘0’.
3. The third most significant bit, adjacent to the second MSB, in the Gray code
number is obtained by adding the second MSB and the third MSB in the binary
number and ignoring the carry, if any.
4. The process continues until we obtain the LSB of the Gray code number by the
addition of the LSB and the next higher adjacent bit of the binary number.
EXAMPLE
GRAY CODE TO BINARY CONVERSION

1. Begin with the most significant bit (MSB).


• The MSB of the binary number is the same as the MSB of the Gray code
number.
2. The bit next to the MSB (the second MSB) in the binary number is
obtained by adding the MSB in the binary number to the second MSB in
the Gray code number and disregarding the carry, if any.
3. The third MSB in the binary number is obtained by adding the
second MSB in the binary number to the third MSB in the Gray code
number.
• Again, carry, if any, is to be ignored.
4. The process continues until we obtain the LSB of the binary number.
ASSIGNMENT
• WRITE A REPORT ON THE FOLLOWING ALPHANUMERIC CODES
• ASCII
• EBCDIC
• UNICODE

• READ ON THE FOLLOWING ERROR DETECTION AND CORRECTION


CODES
• PARITY
• REPITITION
• CYCLIC REDUNDANCY CODE
• HAMMING CODE

You might also like