Binary To Bcd Converter
Enter the binary value to convert to bcd or BCD to Binary.
Binary:
Binary (Base-2) represents numbers using only 0s and 1s.
BCD:
BCD (Binary-Coded Decimal) encodes each decimal digit separately as a 4-bit binary value.
How to Convert Binary to BCD — Formula:
Binary → Decimal → for each decimal digit: BCD = digit.toString(2).padStart(4, "0").
Example: Binary 10110 = Decimal 22 → BCD: 0010 0010 (2=0010, 2=0010).
Technical Details:
BCD is used in: financial calculators (avoids floating-point errors), digital clocks, electronic meters, and COBOL programming. Each BCD digit uses 4 bits but only values 0000-1001 are valid.
Binary To Bcd Converter:
Convert binary to BCD by first converting to decimal, then encoding each decimal digit as 4 binary bits.
Frequently Asked Questions
How do I convert Binary to BCD?
Binary → Decimal → for each decimal digit: BCD = digit.toString(2).padStart(4, "0").
What is the Binary number system?
Binary (Base-2) represents numbers using only 0s and 1s.
What is the BCD number system?
BCD (Binary-Coded Decimal) encodes each decimal digit separately as a 4-bit binary value.
Where is Binary to BCD conversion used?
BCD is used in: financial calculators (avoids floating-point errors), digital clocks, electronic meters, and COBOL programming. Each BCD digit uses 4 bits but only values 0000-1001 are valid.
Can I convert large binary numbers?
Yes. This converter handles numbers of any practical size. For very large numbers, the conversion is performed using arbitrary-precision arithmetic to ensure accuracy.
How to Convert Binary to BCD (Binary to Binary-Coded Decimal)
BCD (Binary-Coded Decimal) represents each decimal digit as a separate 4-bit binary group. Unlike pure binary where 1001 1001 = 153, in BCD 1001 1001 = 99 (digit 9, digit 9). BCD is used in financial calculators, digital displays (7-segment), clocks, and systems where decimal accuracy is critical — avoiding the rounding errors of binary floating-point.
- Convert the binary number to its decimal equivalent first.
- Take each decimal digit individually.
- Convert each digit to its 4-bit binary representation (0=0000 through 9=1001).
- Concatenate all 4-bit groups — this is the BCD representation.
- Example: binary 11111001₂ = 249₁₀ → BCD: 0010 0100 1001.
Binary to BCD: Common Values
Frequently converted binary values and their BCD equivalents:
| Input | Output |
|---|---|
| 0000 1001 (9₁₀) | BCD: 0000 1001 |
| 0000 1010 (10₁₀) | BCD: 0001 0000 |
| 0110 0100 (100₁₀) | BCD: 0001 0000 0000 |
| 0110 0011 (99₁₀) | BCD: 1001 1001 |
| 1111 1111 (255₁₀) | BCD: 0010 0101 0101 |
| 0010 1000 (40₁₀) | BCD: 0100 0000 |
| 0011 1100 (60₁₀) | BCD: 0110 0000 |
| 0001 0111 (23₁₀) | BCD: 0010 0011 |
| 0001 0010 (18₁₀) | BCD: 0001 1000 |
| 0011 1110 0111 (999₁₀) | BCD: 1001 1001 1001 |
| 1001 1100 0100 0000 (39999₁₀) | BCD: 0011 1001 1001 1001 1001 |
| 0000 0001 (1₁₀) | BCD: 0000 0001 |
Solved Examples: Binary to BCD
Question 1: A timer register holds binary 00111100 (60₁₀). Convert to BCD for a 7-segment display.
Solution:
Binary 00111100 = 60 in decimal.
Decimal 60: digit 6 = 0110, digit 0 = 0000.
BCD: 0110 0000.
Answer: 00111100₂ = 0110 0000 (BCD). The display controller sends 0110 to the tens digit and 0000 to the units digit, showing "60".
Question 2: Convert binary 11111111 (255₁₀) to BCD.
Solution:
Binary 11111111 = 255 in decimal.
Decimal 255: digit 2 = 0010, digit 5 = 0101, digit 5 = 0101.
BCD: 0010 0101 0101.
Answer: 11111111₂ = 0010 0101 0101 (BCD). Note: 8 bits of binary requires 12 bits of BCD (50% more space).
Question 3: A real-time clock chip stores time as BCD. Convert binary 00010111 (23₁₀) to BCD for the hours register.
Solution:
Binary 00010111 = 23 in decimal.
Decimal 23: digit 2 = 0010, digit 3 = 0011.
BCD: 0010 0011.
Answer: 00010111₂ = 0010 0011 (BCD). RTC chips like DS1307 store hours as BCD natively.
Question 4: Convert binary 1111101000 (1000₁₀) to packed BCD.
Solution:
Binary 1111101000 = 1000 in decimal.
Decimal 1000: digits 1, 0, 0, 0.
1=0001, 0=0000, 0=0000, 0=0000.
Packed BCD: 0001 0000 0000 0000.
Answer: 1111101000₂ = 0001 0000 0000 0000 (BCD). The 10-bit binary needs 16 bits in BCD.
Practice: Binary to BCD
Try solving these on your own to test your understanding:
- Convert binary 01011001 (89₁₀) to BCD. (Answer: 1000 1001)
- Convert binary 01100100 (100₁₀) to BCD. (Answer: 0001 0000 0000)
- Convert binary 00010010 (18₁₀) to BCD. (Answer: 0001 1000)
- Convert binary 01110101 (117₁₀) to BCD. (Answer: 0001 0001 0111)
- Convert binary 00001001 (9₁₀) to BCD. (Answer: 0000 1001 — same!)
- Convert binary 11000000 (192₁₀) to BCD. (Answer: 0001 1001 0010)
Packed vs. Unpacked BCD
Packed BCD stores two decimal digits per byte (one in each nibble): the byte 0101 1001 represents 59. Unpacked BCD uses a full byte per digit: 00000101 00001001 represents 59 (upper nibble is zeros or a zone value like 0x30 for ASCII). Packed BCD is space-efficient (2 digits per byte), while unpacked BCD is easier to process and convert to ASCII (just OR with 0x30). Financial systems typically use packed BCD; display drivers often use unpacked.
Where BCD Is Still Used Today
BCD persists in: (1) Real-Time Clock (RTC) chips (DS1307, PCF8563) that store hours/minutes/seconds as BCD; (2) financial calculators and COBOL programs that need exact decimal arithmetic; (3) digital multimeters and industrial displays that drive 7-segment LEDs directly from BCD; (4) the x86 DAA/DAS instructions for BCD arithmetic; (5) embedded systems with limited processing power where BCD-to-display conversion is cheaper than binary-to-decimal division.
Key Takeaways
- BCD converts each decimal digit to a separate 4-bit code (0000-1001).
- First convert binary to decimal, then encode each digit as 4-bit BCD.
- BCD wastes ~20% space vs. pure binary but simplifies display output.
- Invalid BCD nibbles: anything 1010-1111 (values 10-15) cannot occur.
- Packed BCD: 2 digits per byte. Unpacked: 1 digit per byte.
- Used in RTC chips, financial systems, COBOL, and 7-segment displays.