BCD or Binary Coded Decimal
Last Updated :
15 Jul, 2025
Binary Coded Decimal (BCD) is a binary encoding system in which each decimal digit is represented by a fixed number of binary bits, typically four. Instead of converting the entire decimal number into a binary number, BCD represents each decimal digit separately as its binary equivalent.
- BCD powers digital systems like clocks and calculators, making decimal displays possible.
- It’s the go-to choice for systems with human interaction, like digital displays and data entry tools.
- BCD makes arithmetic easier by treating each decimal digit separately.
- Embedded systems rely on BCD for fast and efficient decimal operations.
Working of Binary Coded Decimal
In BCD, each decimal digit (0-9) is converted into its 4-bit binary equivalent. For example:
- Decimal 0 is represented as
0000
in BCD. - Decimal 1 is represented as
0001
in BCD. - Decimal 2 is represented as
0010
in BCD and so on.
For instance, the decimal number 57 would be represented in BCD as two separate 4-bit binary numbers:
- Decimal 5 becomes
0101
- Decimal 7 becomes
0111
So, 57 in BCD is represented as 0101 0111
.
Truth Table for Binary Coded Decimal
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
1. Packed BCD
Packed BCD is a type of Binary Coded Decimal where two decimal digits are stored in one byte (8 bits). In Packed BCD, each 4-bit nibble of a byte represents one decimal digit. Packed BCD saves memory space compared to other methods, as it uses one byte to store two digits, making it efficient for storage and processing in digital systems.
Example: Consider the decimal number 93. In Packed BCD, it is represented as 10010011:
- The first nibble (1001) represents 9.
- The second nibble (0011) represents 3.
2. Unpacked BCD
Unpacked BCD stores each decimal digit in a separate byte. Each byte contains one decimal digit, with the 4-bit nibble representing the decimal digit and the other 4 bits are unused or set to 0. Unpacked BCD uses more memory compared to Packed BCD, as each digit requires one full byte. However, it is simpler to work with in certain systems where each decimal digit needs to be accessed separately.
Example: For the decimal number 93, in Unpacked BCD:
- The first byte is 00001001 (representing 9).
- The second byte is 00000011 (representing 3).
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.
1. BCD Addition
To add two BCD numbers, the sum of each corresponding digit is calculated. If the result exceeds 9 (1001 in binary), a correction factor of 6 (0110 in binary) is added to adjust the result.
Example: Adding decimal numbers 45 and 37 in BCD
Convert to BCD:
- 45 → 0100 0101
- 37 → 0011 0111
0100 0101 (45)
+ 0011 0111 (37)
---------
0111 1100 (7 12)
This is an invalid BCD result as 12 (1100) is greater than 9 (1001) and sum should be equal to 82. For adjustment we add 6 (0110) to the result:
0111 1100 (Invalid result)
+ 0000 0110 (Add correction factor)
------------
1000 0010 (82)
Final BCD result: 1000 0010, which represents the decimal value 82 in BCD.
2. BCD Subtraction
To subtract BCD numbers, similar to addition, borrow adjustments are made when the subtracted digit is greater than the minuend digit. A correction factor of 6 is added when needed.
Example: Subtracting decimal numbers 23 from 47 in BCD
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 represents the decimal value 24.
3. BCD Multiplication
Multiplying BCD numbers requires converting the BCD digits to their binary equivalents, performing the multiplication and then converting the result back to BCD.
Example: Multiplying decimal numbers 5 by 3 in BCD
Convert to BCD:
- 5 → 0101
- 3 → 0011
- 5 x 3 = 15 → 0000 1111
- Convert binary result to BCD: 15 in binary → 0001 0101 in BCD
0101 (5 in binary)
x 0011 (3 in binary)
---------
0000 1111 (15 in binary)
1 → 0001
5 → 0101
15 in BCD form: 0001 0101
Final BCD result: 0001 0101, which represents the decimal value 15.
4. BCD Division
Division follows the same principles as multiplication. The BCD numbers are first converted to binary, divided and then the quotient is converted back to BCD.
Example: Dividing decimal number 18 by 3 in BCD
Convert to BCD:
- 18 → 0001 1000
- 3 → 0011
- 18 ÷ 3 = 6 → 0000 0110
0001 1000 (18 in binary)
÷ 0011 (3 in binary)
------------
0000 0110 (6 in binary)
Convert binary result to BCD: 6 in binary → 0110 in BCD
Final BCD result: 0110, which represents the decimal value 6.
Limitations of BCD
1. Inefficient Use of Memory: BCD uses more memory than pure binary representation. Each decimal digit is represented by 4 bits, leading to higher memory consumption compared to binary.
2. Complex Arithmetic Operations: Performing arithmetic operations like addition and multiplication is more complex in BCD. Extra correction factors are required when the result exceeds 9, making the process slower.
3. Slower Processing Speed: Due to the need for additional correction and conversion steps, BCD operations take longer than binary operations, affecting processing speed.
4. Limited Range: BCD can represent only decimal digits (0-9). It cannot handle fractional values efficiently without additional complexity, limiting its versatility in certain applications.
5. Hardware Overhead: Specialized hardware is required to handle BCD operations, which adds to the overall cost and complexity of digital systems.
Applications of BCD
1. Digital Displays: BCD is used in devices like digital clocks and calculators to show decimal numbers as binary values, making it easier to display numbers on screens.
2. Embedded Systems: In embedded systems, BCD is ideal for processing or displaying decimal values, such as in financial applications, counters and digital instruments.
3. Data Conversion: When decimal numbers need to be converted to binary or vice versa, BCD simplifies the process, which is useful in barcode scanners and other input devices.
4. Arithmetic Operations: BCD is crucial in systems that perform decimal-based arithmetic, as it allows easier and more accurate handling of decimal digits in addition, subtraction and multiplication.
5. Control Systems: BCD plays a key role in control systems where decimal input and output are needed for precise decision-making and data processing.
Similar Reads
Basics & Prerequisites
Data Structures
Array Data StructureIn this article, we introduce array, implementation in different popular languages, its basic operations and commonly seen problems / interview questions. An array stores items (in case of C/C++ and Java Primitive Arrays) or their references (in case of Python, JS, Java Non-Primitive) at contiguous
3 min read
String in Data StructureA string is a sequence of characters. The following facts make string an interesting data structure.Small set of elements. Unlike normal array, strings typically have smaller set of items. For example, lowercase English alphabet has only 26 characters. ASCII has only 256 characters.Strings are immut
2 min read
Hashing in Data StructureHashing is a technique used in data structures that efficiently stores and retrieves data in a way that allows for quick access. Hashing involves mapping data to a specific index in a hash table (an array of items) using a hash function. It enables fast retrieval of information based on its key. The
2 min read
Linked List Data StructureA linked list is a fundamental data structure in computer science. It mainly allows efficient insertion and deletion operations compared to arrays. Like arrays, it is also used to implement other data structures like stack, queue and deque. Hereâs the comparison of Linked List vs Arrays Linked List:
2 min read
Stack Data StructureA Stack is a linear data structure that follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out). LIFO implies that the element that is inserted last, comes out first and FILO implies that the element that is inserted first
2 min read
Queue Data StructureA Queue Data Structure is a fundamental concept in computer science used for storing and managing data in a specific order. It follows the principle of "First in, First out" (FIFO), where the first element added to the queue is the first one to be removed. It is used as a buffer in computer systems
2 min read
Tree Data StructureTree Data Structure is a non-linear data structure in which a collection of elements known as nodes are connected to each other via edges such that there exists exactly one path between any two nodes. Types of TreeBinary Tree : Every node has at most two childrenTernary Tree : Every node has at most
4 min read
Graph Data StructureGraph Data Structure is a collection of nodes connected by edges. It's used to represent relationships between different entities. If you are looking for topic-wise list of problems on different topics like DFS, BFS, Topological Sort, Shortest Path, etc., please refer to Graph Algorithms. Basics of
3 min read
Trie Data StructureThe Trie data structure is a tree-like structure used for storing a dynamic set of strings. It allows for efficient retrieval and storage of keys, making it highly effective in handling large datasets. Trie supports operations such as insertion, search, deletion of keys, and prefix searches. In this
15+ min read
Algorithms
Searching AlgorithmsSearching algorithms are essential tools in computer science used to locate specific items within a collection of data. In this tutorial, we are mainly going to focus upon searching in an array. When we search an item in an array, there are two most common algorithms used based on the type of input
2 min read
Sorting AlgorithmsA Sorting Algorithm is used to rearrange a given array or list of elements in an order. For example, a given array [10, 20, 5, 2] becomes [2, 5, 10, 20] after sorting in increasing order and becomes [20, 10, 5, 2] after sorting in decreasing order. There exist different sorting algorithms for differ
3 min read
Introduction to RecursionThe process in which a function calls itself directly or indirectly is called recursion and the corresponding function is called a recursive function. A recursive algorithm takes one step toward solution and then recursively call itself to further move. The algorithm stops once we reach the solution
14 min read
Greedy AlgorithmsGreedy algorithms are a class of algorithms that make locally optimal choices at each step with the hope of finding a global optimum solution. At every step of the algorithm, we make a choice that looks the best at the moment. To make the choice, we sometimes sort the array so that we can always get
3 min read
Graph AlgorithmsGraph is a non-linear data structure like tree data structure. The limitation of tree is, it can only represent hierarchical data. For situations where nodes or vertices are randomly connected with each other other, we use Graph. Example situations where we use graph data structure are, a social net
3 min read
Dynamic Programming or DPDynamic Programming is an algorithmic technique with the following properties.It is mainly an optimization over plain recursion. Wherever we see a recursive solution that has repeated calls for the same inputs, we can optimize it using Dynamic Programming. The idea is to simply store the results of
3 min read
Bitwise AlgorithmsBitwise algorithms in Data Structures and Algorithms (DSA) involve manipulating individual bits of binary representations of numbers to perform operations efficiently. These algorithms utilize bitwise operators like AND, OR, XOR, NOT, Left Shift, and Right Shift.BasicsIntroduction to Bitwise Algorit
4 min read
Advanced
Segment TreeSegment Tree is a data structure that allows efficient querying and updating of intervals or segments of an array. It is particularly useful for problems involving range queries, such as finding the sum, minimum, maximum, or any other operation over a specific range of elements in an array. The tree
3 min read
Pattern SearchingPattern searching algorithms are essential tools in computer science and data processing. These algorithms are designed to efficiently find a particular pattern within a larger set of data. Patten SearchingImportant Pattern Searching Algorithms:Naive String Matching : A Simple Algorithm that works i
2 min read
GeometryGeometry is a branch of mathematics that studies the properties, measurements, and relationships of points, lines, angles, surfaces, and solids. From basic lines and angles to complex structures, it helps us understand the world around us.Geometry for Students and BeginnersThis section covers key br
2 min read
Interview Preparation
Practice Problem