2.
Number Systems and Digital Codes
• Decimal & Binary Numbers and their Conversions
• Hexadecimal and Octal Numbers
• Binary Coded Decimal (BCD) and Digital Codes
Binary Coded Decimal (BCD) and Digital Codes
Lesson Outlines Lesson Objectives
1. Binary Coded Decimal (BCD) ▪ To clearly understand the Binary
2. The Gray Code Coded Decimal (BCD) and the
3. Binary-to-Gray Code Conversion Digital Codes
4. Gray-to-Binary Code Conversion
5. ASCII Code
2
ㅡ
Faculty of Computer Systems and Technologies 10
Binary Coded Decimal (BCD) and Digital Codes
1. Binary Coded Decimal (BCD)
• express each of the decimal digits with a binary Code
• only ten code groups
Decimal to BCD Conversion
BCD to Decimal Conversion
3
ㅡ
Faculty of Computer Systems and Technologies 10
Binary Coded Decimal (BCD) and Digital Codes
2. The Gray Code
• no specific weights assigned to the bit positions
• a single bit change from one code word to the next in sequence
Four-bit Gray code 4
ㅡ
Faculty of Computer Systems and Technologies 10
Binary Coded Decimal (BCD) and Digital Codes
3. Binary-to-Gray Code Conversion
• Left-most in the Gray code is the same as MSB in the binary number.
• Going from left to right, add each adjacent pair of binary code bits to get the
next Gray code bit. Discard carries.
EXAMPLE 2–1
Convert the binary number 10110 to Gray code.
Solution:
5
ㅡ
Faculty of Computer Systems and Technologies 10
Binary Coded Decimal (BCD) and Digital Codes
4. Gray-to-Binary Code Conversion
• The most significant bit (left-most) in the binary code is the same as the
corresponding bit in the Gray code
• Add each binary code bit generated to the Gray code bit in the next adjacent
position. Discard carries.
EXAMPLE 2–2
Convert the Gray code word 11011 to binary.
Solution:
6
ㅡ
Faculty of Computer Systems and Technologies 10
Binary Coded Decimal (BCD) and Digital Codes
5. ASCII Code
• American Standard Code for Information Interchange
• ASCII has 128 characters and symbols represented by a 7-bit binary code.
EXAMPLE 2–3 Convert the ASCII code “ if x>5 “ to binary and hexadecimal.
Solution:
7
ㅡ
Faculty of Computer Systems and Technologies 10
Binary Coded Decimal (BCD) and Digital Codes
https://commons.wikimedia.org/wiki/File:
ASCII-Table-wide.svg
8
ㅡ
Faculty of Computer Systems and Technologies 10
Binary Coded Decimal (BCD) and Digital Codes
Quiz
1. The BCD number for decimal 473 is ----------------.
2. Convert the BCD numbers “001000110111” to decimal. ------------------
3. Convert the decimal numbers “156” to 8421 BCD. -----------------------
4. Convert the binary number “1111011101110” to Gray code. ---------------------
5. Convert the Gray code “11000010001” to binary. ------------------------
9
ㅡ
Faculty of Computer Systems and Technologies 10
Thank You
For your attention
10
ㅡ
Faculty of Computer Systems and Technologies 10