Bcd To Binary Converter
Enter the bcd value to convert to binary or Binary to BCD.
BCD:
BCD (Binary-Coded Decimal) represents each decimal digit as a separate 4-bit binary group.
Binary:
Binary (Base-2) is the standard binary representation of the full number.
How to Convert BCD to Binary — Formula:
For each 4-bit BCD group: digit = parseInt(group, 2). Combine digits to decimal, then decimal.toString(2).
Example: BCD 0010 0010 → digits 2, 2 → Decimal 22 → Binary 10110.
Technical Details:
BCD wastes some bit patterns (1010-1111 are invalid per digit) but simplifies decimal display. Packed BCD stores 2 digits per byte. Unpacked BCD uses 1 byte per digit.
Bcd To Binary Converter:
Convert BCD to binary by decoding each 4-bit group to a decimal digit, then converting the full decimal to binary.
Frequently Asked Questions
How do I convert BCD to Binary?
For each 4-bit BCD group: digit = parseInt(group, 2). Combine digits to decimal, then decimal.toString(2).
What is the BCD number system?
BCD (Binary-Coded Decimal) represents each decimal digit as a separate 4-bit binary group.
What is the Binary number system?
Binary (Base-2) is the standard binary representation of the full number.
Where is BCD to Binary conversion used?
BCD wastes some bit patterns (1010-1111 are invalid per digit) but simplifies decimal display. Packed BCD stores 2 digits per byte. Unpacked BCD uses 1 byte per digit.
Can I convert large bcd 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 BCD to Binary (Binary-Coded Decimal to Pure Binary)
Converting BCD back to pure binary is needed when reading data from RTC (Real-Time Clock) chips, processing COBOL data files, or interfacing with BCD-based measurement instruments. The process reverses BCD encoding: extract each 4-bit group as a decimal digit, form the decimal number, then convert to binary.
- Split the BCD value into 4-bit nibbles.
- Convert each nibble to its decimal digit (0000=0 through 1001=9).
- Combine the digits to form the decimal number (leftmost = most significant).
- Convert the decimal number to binary using repeated division by 2.
- Example: BCD 0100 0010 → digits 4, 2 → decimal 42 → binary 101010.
BCD to Binary: Common Values
Typical BCD values from RTC chips and displays, and their binary equivalents:
| Input | Output |
|---|---|
| BCD: 0000 1001 (09) | 00001001 (9₁₀) |
| BCD: 0001 0000 (10) | 00001010 (10₁₀) |
| BCD: 0010 0011 (23) | 00010111 (23₁₀) |
| BCD: 0101 1001 (59) | 00111011 (59₁₀) |
| BCD: 1001 1001 (99) | 01100011 (99₁₀) |
| BCD: 0001 0010 (12) | 00001100 (12₁₀) |
| BCD: 0011 0001 (31) | 00011111 (31₁₀) |
| BCD: 0010 0100 (24) | 00011000 (24₁₀) |
| BCD: 0001 0010 0111 (127) | 01111111 (127₁₀) |
| BCD: 0010 0101 0101 (255) | 11111111 (255₁₀) |
| BCD: 0100 0010 (42) | 00101010 (42₁₀) |
| BCD: 0000 0000 (00) | 00000000 (0₁₀) |
Solved Examples: BCD to Binary
Question 1: A DS1307 RTC chip returns 0x59 for seconds register (stored as BCD). Convert to binary for time calculations.
Solution:
BCD byte: 0101 1001
High nibble: 0101 = 5 (tens digit)
Low nibble: 1001 = 9 (units digit)
Decimal value: 59
Convert 59 to binary: 59 = 32+16+8+2+1 = 111011₂
Answer: BCD 0101 1001 = 59₁₀ = 00111011₂. The code: seconds = (bcd >> 4) * 10 + (bcd & 0x0F).
Question 2: Convert BCD 0010 0100 0000 0011 (the number 2403) to binary.
Solution:
Nibbles: 0010=2, 0100=4, 0000=0, 0011=3
Decimal: 2403
2403 ÷ 2 = 1201 R1, 1201÷2=600 R1, 600÷2=300 R0
300÷2=150 R0, 150÷2=75 R0, 75÷2=37 R1
37÷2=18 R1, 18÷2=9 R0, 9÷2=4 R1, 4÷2=2 R0, 2÷2=1 R0, 1÷2=0 R1
Binary (bottom to top): 100101100011
Answer: BCD 2403 = 100101100011₂ (verify: 2048+256+64+32+2+1 = 2403 ✓).
Question 3: An embedded clock reads hour register as BCD 0010 0011. Convert to binary for arithmetic.
Solution:
High nibble: 0010 = 2
Low nibble: 0011 = 3
Decimal: 23
Binary: 23 = 16+4+2+1 = 10111₂
Answer: BCD 0010 0011 = 23₁₀ = 10111₂. This represents 11 PM in 24-hour format.
Question 4: A digital multimeter outputs BCD 0001 0010 0011 0100. Convert to binary.
Solution:
Nibbles: 0001=1, 0010=2, 0011=3, 0100=4
Decimal: 1234
1234 = 1024+128+64+16+2 = 10011010010₂
Answer: BCD 1234 = 10011010010₂ (verify: 1024+128+64+16+2 = 1234 ✓).
Practice: BCD to Binary
Try solving these on your own to test your understanding:
- Convert BCD 1000 0101 (85) to binary. (Answer: 1010101, which is 85₁₀)
- Convert BCD 0100 0010 (42) to binary. (Answer: 101010, which is 42₁₀)
- Convert BCD 0001 0000 (10) to binary. (Answer: 1010, which is 10₁₀)
- Convert BCD 0101 1001 (59) to binary. (Answer: 111011, which is 59₁₀)
- Convert BCD 1001 1001 (99) to binary. (Answer: 1100011, which is 99₁₀)
- Is 1010 0101 valid BCD? (Answer: No — first nibble 1010 = 10, which exceeds 9)
Programming BCD Conversion: The Formula
The standard code for BCD-to-binary conversion in embedded systems: decimal_value = (bcd_byte >> 4) * 10 + (bcd_byte & 0x0F). This shifts the high nibble right by 4 to get the tens digit, multiplies by 10, then adds the low nibble (units digit). For multi-byte BCD, process each byte and combine: total = hundreds*100 + tens_units. The reverse (binary to BCD, called "Double Dabble" algorithm) is more complex, involving left-shift and add-3-if-≥5 operations.
The Double Dabble Algorithm
Converting binary to BCD without first going through decimal uses the Double Dabble (shift-and-add-3) algorithm: (1) Set up BCD result registers initialized to 0. (2) Shift binary left, MSB goes into BCD LSB. (3) After each shift, check each BCD nibble: if ≥ 5, add 3. (4) Repeat for all binary bits. This hardware-friendly algorithm is implemented in FPGAs and microcontrollers that need to drive BCD displays directly from binary counters without division.
Key Takeaways
- Split BCD into 4-bit nibbles, decode each as a decimal digit, then convert to binary.
- Standard formula: value = (high_nibble × 10) + low_nibble.
- Validate input: any nibble ≥ 1010 means invalid/corrupted BCD.
- Used when reading RTC chips, processing COBOL files, or interfacing displays.
- The Double Dabble algorithm converts binary→BCD in hardware without division.
- BCD is space-inefficient (4 bits per digit) but simplifies decimal display.