Decimal to BCD Converter

Encodes a decimal (base-10) integer as Binary-Coded Decimal by converting each individual digit to its own 4-bit binary nibble, producing space-separated groups of 4 binary digits. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-27

Overview

Introduction

Binary-Coded Decimal is the standard way to represent decimal digits in digital hardware, like seven-segment displays and old calculator chips, where each visible digit needs its own clean binary code.

This tool encodes a plain decimal number into BCD by converting each digit independently into a 4-bit nibble.

What Is Decimal to BCD Converter?

An encoder that takes a decimal integer and outputs its Binary-Coded Decimal representation, one 4-bit nibble per digit.

Unlike converting the whole number to binary at once, BCD preserves a direct, human-readable correspondence between each digit and its own 4 bits.

How Decimal to BCD Converter Works

The input is validated to be a non-negative whole number using only digits 0-9.

Each character (digit) of that string is individually parsed and converted to a 4-bit binary string, zero-padded to 4 digits, and the resulting nibbles are joined with spaces in the original digit order.

When To Use Decimal to BCD Converter

Use it to prepare decimal values for BCD-based display drivers, calculator simulations, or embedded systems coursework.

It's also a clear way to teach the distinction between pure binary and digit-wise BCD encoding.

Features

Advantages

  • Simple, direct mapping that's easy to verify by hand, digit by digit.
  • Works on decimal numbers of any length, since each digit is processed independently.
  • Produces cleanly delimited nibbles that are easy to read and split apart.

Limitations

  • Only supports non-negative integers — no sign digit, decimal point, or fractional part is handled.
  • Less space-efficient than pure binary, since 4 bits per digit only ever use 10 of their 16 possible values.

Examples

A 3-digit number

Input

123

Output

0001 0010 0011

Digit 1 -> 0001, digit 2 -> 0010, digit 3 -> 0011.

A number containing a zero digit

Input

905

Output

1001 0000 0101

Digit 9 -> 1001, digit 0 -> 0000, digit 5 -> 0101.

Best Practices & Notes

Best Practices

  • Count your output nibbles — there should be exactly one nibble per digit in the input.
  • Use the BCD to Decimal Converter to confirm the encoding round-trips back to the original number.

Developer Notes

Implemented as a per-character map: `digit => parseInt(digit, 10).toString(2).padStart(4, "0")`, joined with spaces — no BigInt is needed since each digit is always 0-9.

Decimal to BCD Converter Use Cases

  • Preparing decimal values for a BCD-driven seven-segment display simulation
  • Teaching or demonstrating BCD encoding with concrete digit-by-digit examples
  • Generating BCD test vectors for calculator or embedded-systems coursework

Common Mistakes

  • Expecting a single compact binary number instead of one nibble per digit — that's what a plain decimal-to-binary converter produces, not BCD.
  • Entering a negative number or decimal point, neither of which this basic BCD encoding supports.

Tips

  • Try encoding a number with a 9 in it, the largest single BCD digit, to see the 1001 nibble in context.
  • Chain the output into the BCD to Octal Converter to see the same value expressed in octal.

References

Frequently Asked Questions