# Binary Coded Decimal (BCD)

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

When I finished calculator Conversion of fractional numbers between numeral systems I thought that 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 which appears during convertion of fractional numbers from one numeral system to another is the loss of precision.

As example I used decimal 0.8, which can't be translated to binary system without precision error.

Since decimal numbers are "native" for human, and binary numbers are "native" for computer, the problem of precision (for these particular numeral systems) once got a solution - invention of binary coded decimal (BCD) format. 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 idea was tuned. Since 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 becomes 0110.01110101.

Good idea - no precision loss, convertation can be done with ease, rounding is simple - just shift unnecessary nibble. But it wasn't widely adopted, cause 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 old curious thing and I haven't known anything about it until I was told by site users.

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

Save the calculation to reuse next time, toextensionembed in your website orshareshare with friends.

## Comments