1a. Binary Vs BCD Code
1a. Binary Vs BCD Code
M. Morris Mano
Edition 5
BINARY CODES
An n‐bit binary code is a group of n bits that assumes up to 2n distinct combinations of 0’s and 1’s,
A B C 5‐
2‐bit Binary code. 3‐bit Binary code. Dec.
0D 0
A B 0 0 00 bit B
A Dec.
Dec. C 1 0 000 I
B
0 0 0
0 0 2 0 101 N
0
This method requires that we store the decimal numbers in the computer in such a way that
they can be converted to binary.
Since the computer can accept only binary values, we must represent the decimal digits by a
code that contains 1s and 0s.
It is also possible to perform the arithmetic operations directly with decimal numbers when
they are stored in the computer in coded form.
BINARY CODED DECIMAL – (BCD)
The code used for the decimal digits (0 to 9) is the straightforward binary assignment and is
called binary-coded decimal (BCD) as shown below:
Dec. A B C
0D 0 As the number of elements in this set is not a power of 2, So this
0 0 00 binary code will have some unassigned bit combinations.
1 0 000
2 0 101
3 011 Unused bit for BCD:
0 1 0
4 10 1 01
0 1
5 00 1 011
0 1 1 10
6 11
0 1 1 010
7 01 1 11
1 0
10 01
8 1 0 1
9 0
0
1
BINARY CODED DECIMAL – (BCD)
BCD Code: BCD
A B C
Dec.
0D 0
Binary Number
0 0 00 0 0000
1 0 000 0000
2 101 1 0001 A number with n
0
3 0 011 0001 decimal digits will
4 10 -- --- require 4*n bits in
0 1
00 --- BCD.
5 0 1
11 -- ---
6 0 1 --
7 01
1 0 9 1001
8 10 1001
1 0
9 0
0 10 0001 0000
1 1010
• BCD number needs more 11 bits than its equivalent
0001
binary0001
value.
1011
• However, BCD representation
-- of decimal numbers is still important, because computer input
and output data used by- most
- people needs to be in the decimal system.
99 1001 1001
BINARY CODED DECIMAL – (BCD)
• BCD numbers are decimal numbers and not binary numbers, even
though they are represented using bits.
- BCD numbers use the binary codes 0000, 0001, 0010, ...,
1001.
DECIMAL CODES
Other decimal codes are possible but not commonly used.
• 2 4 2 1 Code
• Excess-3 Code
• 8 4 -2 -1 code
• Reflected Code