The 8421 BCD Code
BCD stands for Binary-Coded Decimal.
A BCD number is a four-bit binary group that
represents one of the ten decimal digits 0
through 9.
Example:
Decimal number 4926
8421 BCD coded number 0100 1001 0010 0110
QUIZ
Convert the BCD coded number
1000 0111 0001 into decimal.
BCD Coded Number
Decimal Number
1000 0111 0001
8
QUIZ
Convert the decimal number
350 to its BCD equivalent.
Decimal Number
BCD Coded Number
0011 0101 0000
The Excess-3 Code
Add 3 to each digit of decimal
and convert to 4-bit binary form
A BCD code (not 8421 BCD)
Decimal Binary +3 Excess-3
0
0000 0011 0011
1
0001 0011 0100
2
0010 0011 0101
3
0011 0011 0110
4
0100 0011 0111
5
0101 0011 1000
6
0110 0011 1001
7
0111 0011 1010
8
1000 0011 1011
9
1001 0011 1100
Sample Problem:
Decimal
Excess-3
0110 1000 1100
QUIZ
1. To form an excess-3 coded number,
decimal 3 is added to the decimal
number and this is converted to its
4-bit binary code. (True or False)
True
2. The excess-3 BCD number 1010 0100
equals __________ in decimal.
71
3. The decimal number 428 equals
what excess-3 number.
0111 0101 1011
The Gray Code
The Gray codes most
important characteristic is
that only one digit changes
as you increment or
decrement the count.
The Gray code is commonly
associated with input/output
devices such as an optical
encoder of a shafts angular
position.
The Gray code is NOT a BCD
code.
Decimal
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Gray code
00000
00001
00011
00010
00110
00111
00101
00100
01100
01101
01111
01110
01010
01011
01001
01000
11000
QUIZ
1. The Gray code is not a type of BCD
code. (True or False)
2. The most important characteristic
of the ____________ (BCD, Gray
code) is that only one digit changes
state as you increment or decrement
the count.
3. The Gray code is commonly
associated with input/output devices
such as an optical encoder of a
shafts angular position. (True or
False)
True
Gray code
True
The
ASCII
Code
ASCII is an acronym for American
Standard Code for Information
Interchange
Represents numbers, letters, punctuation
marks and control characters
Standard ASCII is a 7-bit code (127
characters)
Extended ASCII (IBM ASCII), an 8-bit code,
is also very popular
Extended ASCII adds graphics and math
symbols to code (total of 256 symbols)
QUIZ
1. A common 7-bit code used to represent
numbers, letters, punctuation marks,
and control characters is known by
the acronym __________.
2. The acronym ASCII stands for
__________________________.
3. Extended ASCII code is a(n)
__________ (8-bit, 10-bit) code
which adds graphic and math
symbols to ASCII for a total of
256 symbols.
ASCII
American Standard
Code for Information
Interchange
8-bit
2s Complement Notation
2s complement representation - widely
used in microprocessors.
Represents sign and magnitude
MSB
LSB
Sign bit (0 = + ; 1 = -)
Decimal:
-7
2s Complement:
1001
+7
+4
0111
0100
+1
0001
0
0000
-1
-4
1111
1100
2s Complement - Conversions
Converting
positive numbers to 2s complement:
Same as converting to binary
Converting negative numbers to 2s complement:
Decimal to 2s
Complement
- 4 (decimal)
Convert decimal
to binary
0100
1s
complement
1011
Add 1
- 4 = 1 1 0 0 (2s Complement)
2s Complement to
Binary
1 1 0 0 (2s C)
0011
1s
complement
Add 1
0 1 0 0 (Binary)
QUIZ
Q#1Convert
the
decimal
number
4
toto2s2scomplement.
Q#2Convert
the
decimal
number
-7
complement.
Q#3Convert
the
decimal
number
1
toto2s
complement.
Q#4Convert
the
decimal
number
+6
2s
Q#5- Convert the decimal number -8 to 2s complement.
complement.
47(decimal)
16(decimal)
(decimal)
8 (decimal)
(decimal)
0100
0111
0001
0110
1000
1011
1000
Not1110
needed
0111
1100
2s
CC
1001
2s
1111
2s
C
Not
needed
1000
2sC
Step 1: convert decimal to binary
Step 2: convert to 1s complement
Step 3: add +1 equaling 2s complement
ANS:
-4
2sC
ANS:
-7-1===1100
1001
2sC
ANS:
1111
2sC
ANS:
+6
=
0110
ANS: -8 = 1000 2sC
2sC
QUIZ
Q#1Convert
the
2s
complement
number
1110
totodecimal.
Q#2Convert
the
2s
complement
number
0101
decimal.
Q#3Convert
the
2s
complement
number
1001
Q#4- Convert the 2s complement number 1111 to
to decimal.
decimal.
Not1110
needed
1001
1111
Step 1: convert to 1s complement
Not0001
needed
0110
0000
Step 2: Add +1
0010
binary
0101
binary
0111
0001binary
binary
Step 3: convert binary to decimal
25decimal
71decimal
decimal
decimal
ANS:
1110
2sC
==-2
decimal
ANS:
0101
2sC
+5
decimal
ANS:
1001
2sC
=
-7
ANS: 1111 2sC = -1 decimal
decimal
Adding/Subtracting in 2s Complement
2s complement notation makes it possible
to add and subtract signed numbers
(Decimal
)
(- 1)
+ (- 2)
(- 3)
2s
Complement
1111
+ 111
0
1 1 1 0 1 2s complement
Discar
d
(+1)
+ (- 3)
(- 2)
0001
+ 110
1
11 1 0
2s complement
QUIZ
Add the following 2s complement numbers:
(+5)
+ (4)
(+1)
0 1 0 1
+ 1 1 0
0
10 0 0 1
Discard