What is Binary Coded Decimal
Binary Coded Decimal is a form of binary representation where each denary digit is converted individually into binary, rather than the whole number being converted as a large number.
Example 1 – the number 42
Normally this number would be converted directed to binary as 00101010 as 8 bit binary.
However in binary coded decimal we would convert the number 4 to binary and the number 2 to binary, then simply concatenate(combine) the 2 numbers together
Therefore 42 in BCD binary would be 01000010
Why use BCD?
Why use Binary Coded Decimal?
Binary coded decimal has 3 main advantages
- It is easier for a human to read large binary numbers than if the number is in pure binary
- It is simpler to create hardware than only counts in decimal and uses basic calculation (e.g. digital clocks, simple handheld calculators)
- Binary coded decimal removes the problem of floating point rounding errors, which makes is very useful for handling financial transactions.
BCD Clock Demo
Binary Coded Decimal Clock Demonstration Project
In binary systems decimals numbers are stored using a floating point representation. When representing fractions of a whole some numbers cannot be stored accurately using binary, due to the fractions not fitting perfectly within a binary base 2 system. This results in a floating point rounding error. In financial systems rounding errors are unacceptable and must be dealt within. For this reason binary coded decimal is used instead.
Floating point rounding example
Here is a great example of a floating point binary rounding error. This kind of error is not acceptable in financial transactions.