BCD Converter
Encode each decimal digit as four bits.
What it does
Binary coded decimal, usually shortened to BCD, represents a decimal number by encoding each of its digits with a four bit binary pattern. The common 8421 code uses bit weights eight, four, two and one.
MIT notes on codes introduce BCD as a case where some four bit patterns are unused, and discuss how a decoder might handle them.
University of Southern California number system notes give the example of 439 in decimal becoming 0100 0011 1001 in BCD, and note that pure binary would be 110110111.
This tool converts a nonnegative integer up to 99,999,999 into BCD groups and the concatenated bit string.
BCD is still used in systems where exact decimal representation matters, such as financial calculations and some display hardware.
How to use
- Enter a whole number from 0 to 99,999,999.
- Read the four bit group for each decimal digit.
- Check the concatenated BCD bit string.
- Compare with the ordinary binary representation if you know it.
- Try 439 to reproduce the published example.
- Note that leading zeros in the input are not preserved.
Formula
- digit
- One decimal digit from 0 to 9.
- 8421
- Bit weights for standard BCD.
- nibble
- A group of four bits representing one digit.
- BCD
- The concatenation of all digit nibbles.
The engine converts each character of the decimal string to its numeric digit and pads its binary form to four bits. It does not include a prefix or spacing beyond the grouped display.
Worked example
Example: 439
Input decimal number 439.
- The first digit 4 becomes 0100 in four bit binary.
- The second digit 3 becomes 0011.
- The third digit 9 becomes 1001.
- Joining them gives 0100 0011 1001.
- The tool reports BCD groups 0100 0011 1001 and plain bits 010000111001.
- Ordinary binary for 439 is 110110111, which uses fewer bits.
Reference table
| Digit | BCD | Digit | BCD |
|---|---|---|---|
| 0 | 0000 | 5 | 0101 |
| 1 | 0001 | 6 | 0110 |
| 2 | 0010 | 7 | 0111 |
| 3 | 0011 | 8 | 1000 |
| 4 | 0100 | 9 | 1001 |
Limits
- Inputs are limited to 99,999,999.
- The tool encodes integers only, not fractions.
- It uses standard 8421 BCD, not excess-3 or other variants.
- Leading zeros in the input are dropped.
Common mistakes
- Assuming BCD is the same as converting the whole number to binary.
- Entering a decimal fraction, which the tool rejects.
- Expecting bit patterns above 1001, which are invalid in BCD.
- Confusing BCD with ASCII digits, which use seven or eight bits.
- Thinking BCD is more compact than binary.
Try it yourself
Quick checks. Answers sit tucked under each question.
What is 439 in BCD?
0100 0011 1001.
How many bits per digit does BCD use?
Four.
Why use BCD?
It preserves exact decimal digits for display and financial work.
Questions
What is BCD?
A binary encoding where each decimal digit gets its own four bit code.
What is 8421?
The weights of the four bits in standard BCD.
Is BCD efficient?
Less efficient than pure binary but convenient for decimal data.
Can it encode fractions?
Not with this tool, which takes integers.
Where is BCD used?
In some calculators, displays and financial systems.
What is excess-3?
A related code that adds three to each digit before encoding.