BCD (Binary-Coded Decimal) Converter
Turn a decimal number into packed and unpacked binary-coded decimal, one four-bit group per digit, or decode groups of BCD bits back to a decimal number.
Use the tool
Why this tool exists
Binary-coded decimal stores each digit in its own four bits instead of converting the whole number to binary. Real-time clock chips, seven-segment displays, some payment terminals and mainframe formats still use it, because each digit can be shown or read without arithmetic.
If you are reading a register from a datasheet or checking a protocol field, you need a quick way to go between the two forms. This converter writes 2026 as 0010 0000 0010 0110 in packed form, shows the matching hex, and shows the unpacked form with a zero nibble ahead of each digit. In the other direction, it rejects any nibble above 9, which is not valid BCD.
How to use it
- Choose decimal to BCD, or BCD to decimal.
- Enter the digits, or groups of four bits, in the input.
- Read the packed, hex and unpacked forms, or the decoded number.
Frequently asked questions
What is the difference between packed and unpacked BCD?
Packed BCD puts two digits in each byte, one per nibble. Unpacked BCD uses a whole byte per digit with the upper four bits set to zero, so it takes twice the space.
Why is a nibble above 9 an error?
Four bits can hold 0 to 15, but BCD only uses 0 to 9 for digits. Values 10 to 15 are not valid, so the decoder reports the offending nibble.
Does it handle negative numbers or decimals?
No. It converts non-negative whole numbers made of digits only. Sign nibbles and decimal points differ between BCD formats, so they are not modelled.
Why does the hex line match the decimal?
In packed BCD each nibble holds one digit, so the hexadecimal reading of the bytes is the same digits as the decimal number. An odd digit count gets a leading zero.