Binary Coded Decimal (BCD) is a method of representing decimal numbers in binary, where each decimal digit is stored separately using a 4-bit binary code. This makes decimal values easier to display and process in digital systems.
- It represents each decimal digit independently, simplifying decimal data processing.
- Maintains accurate decimal representation by encoding each digit separately.
Working
In BCD, each decimal digit (0–9) is converted into its corresponding 4-bit binary code. Every digit is encoded separately instead of converting the entire decimal number into binary.
For example:
- Decimal 0 → 0000
- Decimal 1 → 0001
- Decimal 2 → 0010
- ...
- Decimal 9 → 1001
Example: Represent the decimal number 57 in BCD.
- Digit 5 → 0101
- Digit 7 → 0111
BCD representation of 57: 0101 0111
Truth Table
| Decimal Number | BCD |
|---|---|
| 0 | 0000 |
| 1 | 0001 |
| 2 | 0010 |
| 3 | 0011 |
| 4 | 0100 |
| 5 | 0101 |
| 6 | 0110 |
| 7 | 0111 |
| 8 | 1000 |
| 9 | 1001 |
BCD Representation Techniques
Packed BCD
Packed BCD stores two decimal digits in a single byte (8 bits). Each 4-bit nibble represents one decimal digit, allowing two digits to be stored together and making better use of memory.
Example: Decimal number 93
- 9 → 1001
- 3 → 0011
Packed BCD: 10010011
Unpacked BCD
Unpacked BCD stores one decimal digit per byte. The lower 4 bits store the BCD digit, while the upper 4 bits are usually 0000. Although it uses more memory than Packed BCD, it is easier to process each digit individually.
Example: Decimal number 93
- 9 → 00001001
- 3 → 00000011
Unpacked BCD: 00001001 00000011
Common Operations on BCD Numbers
Common Operations on BCD Numbers involve basic arithmetic operations like addition, subtraction, multiplication and division, with specific rules for handling BCD numbers.
BCD Addition
To add two BCD numbers, add the corresponding 4-bit groups as normal binary numbers. If the sum of any 4-bit group is greater than 1001 (9) or generates a carry, 0110 (6) is added as a correction to obtain a valid BCD result.
Example: Add 45 and 37 in BCD.
Convert to BCD:
- 45 → 0100 0101
- 37 → 0011 0111
0100 0101 (45)
+ 0011 0111 (37)
---------
0111 1100 (7 12)
Since the lower nibble (1100 = 12) is greater than 9 (1001), add the correction factor 0110 (6) to obtain a valid BCD result:
0111 1100 (Invalid result)
+ 0000 0110 (Add correction factor)
------------
1000 0010 (82)
Final BCD result: 1000 0010, which is the BCD representation of decimal 82.
BCD Subtraction
To subtract two BCD numbers, subtract the corresponding BCD digits. If a borrow occurs or the result is not a valid BCD digit, a correction factor of 0110 (6) is applied where required.
Example: Subtract 23 from 47
Convert to BCD:
- 47 → 0100 0111
- 23 → 0010 0011
0100 0111 (47)
- 0010 0011 (23)
-------------
0010 0100 (24) -> Valid BCD result
Final BCD result: 0010 0100, which is the BCD representation of decimal 24.
BCD Multiplication
BCD multiplication is performed by multiplying the numbers in binary and then converting the result back to BCD.
Example: Multiply 5 by 3
Convert to BCD:
- 5 → 0101
- 3 → 0011
0101 (5 in binary)
x 0011 (3 in binary)
---------
0000 1111 (15 in binary)
Convert the binary result to BCD:
Decimal 15 → 0001 0101
Final BCD result: 0001 0101, which is the BCD representation of decimal 15.
BCD Division
BCD division is performed by dividing the numbers in binary and then converting the quotient back to BCD.
Example: Divide 18 by 3
Convert to BCD:
- 18 → 0001 1000
- 3 → 0011
0001 1000 (18 in binary)
÷ 0011 (3 in binary)
------------
0000 0110 (6 in binary)
Convert the quotient to BCD:
Decimal 6 → 0110
Final BCD result: 0110, which is the BCD representation of decimal 6.
Applications
- Digital Displays: BCD is widely used in digital clocks, calculators, and seven-segment displays because it makes displaying decimal numbers simple and accurate.
- Embedded Systems: Many embedded systems use BCD to process or display decimal values in devices such as digital meters, counters, and financial equipment.
- Data Conversion: BCD simplifies the conversion between decimal and binary formats, making it useful in devices like barcode scanners and data entry systems.
- Decimal Arithmetic: Used in systems that perform decimal calculations where maintaining decimal accuracy is more important than binary efficiency.
- Industrial and Control Systems: Commonly used in control systems and instrumentation where decimal input, output, and monitoring are required.