homechevron_rightProfessionalchevron_rightComputers

Binary Coded Decimal (BCD)

This online calculator converts decimal number to binary code in BCD notation and vice versa

When I finished the calculator Conversion of fractional numbers between numeral systems, I thought this was the final one on numeral systems. However, there appears the reason for another one. As I wrote on the link above, the problem that appears during converting fractional numbers from one numeral system to another is the loss of precision.

For example, I used decimal 0.8, which can't be translated into a binary system without precision error.

Since decimal numbers are "native" for humans, and binary numbers are "native" for the computer, the problem of precision (for these particular numeral systems) once got a solution - the invention of binary coded decimal (BCD) format. The idea was simple - use one byte for each decimal digit. And this byte should hold this digit's binary code. Then, for example, 0.8 becomes 0.00001000.

Well, on second thought, the idea was tuned. Since the upper nibble is always empty (since 9, the maximum, is 1001) - let's use only one nibble for each decimal digit. And this was called packed BCD.
In packed BCD, our 0.8 becomes 0.1000, and, for example, 6.75 become 0110.01110101.

Good idea - no precision loss, conversion can be made with ease, and rounding is simple - just shift unnecessary nibble. But it wasn't widely adopted, because it makes life more difficult... for computers. BCD means more memory to hold numbers and more complex schemes for numbers operations.
So it is just an old curious thing, and I haven't known anything about it until site users told me.

Here is the calculator for BCD. You could enter decimal or packed BCD and get the conversion. Of course, this can be done in mind (and this is the advantage of BCD), but just let the computer do it for you.

PLANETCALC, Binary Coded Decimal (BCD)

Binary Coded Decimal (BCD)

You can enter decimal or binary code in BCD notation
Decimal
 
Binary Coded Decimal
 

URL copied to clipboard
Creative Commons Attribution/Share-Alike License 3.0 (Unported) PLANETCALC, Binary Coded Decimal (BCD)

Comments