Encode a decimal number as BCD – each digit becomes its own 4-bit group, so 429 becomes 0100 0010 1001. Note this is NOT the same as converting the whole number to binary.
Show calculation steps
Processed privately in your browser β nothing you paste is uploaded, logged or stored.
Digits into nibbles
Encoding to BCD maps each decimal digit independently to four bits: 4β0100, 2β0010, 9β1001. No carries, no cross-digit arithmetic β the digit boundaries the decimal system already has are simply preserved in binary dress.
The encoding exists so machines can keep decimal exactness: what humans wrote is what the hardware holds, digit for digit, at the price of about 20% more bits than pure binary.
Worked example
Input: 429 4 β 0100 2 β 0010 9 β 1001 BCD: 0100 0010 1001 (12 bits) Pure binary for contrast: 110101101 (9 bits)
| Digit | BCD | Excess-3 |
|---|---|---|
| 0 | 0000 | 0011 |
| 1 | 0001 | 0100 |
| 2 | 0010 | 0101 |
| 3 | 0011 | 0110 |
| 4 | 0100 | 0111 |
| 5 | 0101 | 1000 |
| 6 | 0110 | 1001 |
| 7 | 0111 | 1010 |
| 8 | 1000 | 1011 |
| 9 | 1001 | 1100 |
Arithmetic on BCD, briefly
Adding BCD nibbles as binary breaks when a digit sum exceeds 9 β the fix is the add-6 correction, skipping the six invalid patterns, with a carry to the next digit. Vintage CPUs shipped instructions for it (x86 DAA, 6502 decimal mode); modern code either uses decimal libraries or converts to binary and back.
When to choose BCD
Display-driving without division, decimal-exact accumulation (currency, metering), and interfacing chips that already speak it. When storage or raw arithmetic speed dominates, pure binary wins β the two pages of this pair exist to keep the trade-off conscious.
Privacy
Per-digit mapping runs in-page; your numbers are not transmitted.
How to use the Decimal to BCD Converter
- Enter the decimal number – digits only.
- Click "Encode as BCD".
- Each digit maps to its own 4-bit group, shown in the steps digit by digit.
- Note the comparison line: BCD is NOT the binary value of the whole number.
Frequently asked questions
How is each digit encoded?
Independently, as its plain 4-bit binary: 4β0100, 2β0010, 9β1001, so 429 β 0100 0010 1001. No cross-digit arithmetic happens – that is the entire point.
Why is BCD different from converting 429 to binary?
429 as a VALUE is 110101101 – nine bits mixing all digits together. BCD keeps digit boundaries: twelve bits, three clean groups. Displays and decimal arithmetic need the digit structure; compact storage prefers the value.
What number range fits in n groups?
Exactly n decimal digits: 4 groups hold 0-9999. Range grows by Γ10 per group, versus Γ16 for a true binary nibble – the unused patterns account for the gap.
Does BCD handle signs or decimals?
Packed-decimal variants add a sign nibble, and fixed decimal points are managed by convention – but plain BCD, and this tool, encode unsigned digit strings. The steps note when input needs a different tool.
Why do RTC chips deliver time in BCD?
So firmware can show digits without dividing by ten: hours 12 arrive as 0001 0010, ready for two seven-segment digits. Reading such a register as plain binary (18) is a classic embedded bug this pair of pages disarms.
Is there a quick mental check?
Group count must equal digit count, and no group may exceed 1001. If either fails, something is mis-encoded – the decoder page enforces both directions.
Is the BCD encoding local to my browser?
Yes – encoding is a per-digit table lookup in the page. Your number is not transmitted.