Decimal to BCD Converter

Decimal to BCD Converter. Type your number into Decimal Input and the Decimal to BCD Converter instantly encodes it into BCD (Binary) Output. Paste a list of decimal numbers into the decimal to binary converter to get their binary equivalents back all at once.

Use this decimal to BCD converter when you need the exact binary coded decimal for a whole number: every decimal digit you type becomes its own 4-bit binary code, so you get one tidy nibble per digit instead of one long string of bits. Type a decimal number such as 6408 and the result reads 0110 0100 0000 1000 straight away, with the 4-bit binary code for each digit shown beside it.

How to Use This Decimal to BCD Converter

The tool is built for speed, whether you are a student checking homework or an engineer verifying a register value. Here is how to use it from start to finish: Students learning how computers store text often turn to the text to binary converter to see the binary code behind each letter.

  1. Enter a decimal number using the digits 0 to 9 only; leave out spaces, commas and signs.
  2. Press the convert button and read the BCD code in the result box, grouped into nibbles for easy reading.
  3. Open the solution steps and the step-by-step conversion to see each digit matched to its 4-bit group, with the 8-4-2-1 weight of every bit position shown as a visualization.
  4. Copy the answer from the display, or clear the field and try a new decimal value to practise.

Because BCD works one digit at a time, the length of the answer is always four bits per digit. A four-digit input gives sixteen bits, a seven-digit input gives twenty-eight, and so on. If you want to go the other way, a BCD to decimal conversion simply reverses the grouping, which the section on reading a code back covers below.

What Binary Coded Decimal Means for a Decimal Number

Binary-coded decimal is a way of storing numbers in which each decimal digit keeps its own small binary field. Ordinary binary rewrites the whole value in base 2, but BCD never mixes digits together: the thousands digit, the hundreds digit and the rest each sit in a separate 4-bit slot. Going from decimal to binary-coded decimal is therefore a lookup on base 10 digits, and that is why engineers in digital electronics still reach for it whenever a number must be shown to a person exactly as typed. Enter a message into the text to hex converter and it maps every character to its hexadecimal code point automatically.

The BCD Encoding Table

Only ten of the sixteen possible 4-bit groups are used. This BCD encoding table is the entire lookup you need, and it is also the 8421 BCD code, named after the bit weights 8, 4, 2 and 1:

The BCD Encoding Table
Decimal digitBCD codeWeights added (8 + 4 + 2 + 1)
000000
100011
200102
300112 + 1
401004
501014 + 1
601104 + 2
701114 + 2 + 1
810008
910018 + 1

Why Six Bit Patterns Stay Unused: Pseudotetrades

Four bits can hold sixteen values, but a digit never exceeds 9. The six leftover groups, 1010 through 1111, are called pseudotetrades. A well-formed BCD value never contains one, so spotting one is the quickest sign that a register holds corrupted data or a half-finished sum. Some designs deliberately reuse these bit patterns for a sign, a separator or a decimal point.

Decimal to BCD Code Formula and Method

The method is a plain lookup in the conversion table above, not arithmetic. For a number with digits \(d_{n-1} \ldots d_1 d_0\), the BCD form is the concatenation of each digit's 4-bit equivalent: The hex color tint calculator lightens a hex color by mixing it toward white at whatever percentage you choose.

$$\text{BCD}(N) = B(d_{n-1})\,B(d_{n-2})\,\ldots\,B(d_0)$$

Each group \(B(d)\) is a 4-bit binary code whose value satisfies:

$$d = 8b_3 + 4b_2 + 2b_1 + 1b_0$$

So the whole job is: split the number into digits, replace every digit with its binary equivalent from the table, and keep the original left-to-right order. Nothing is divided by 2, and no remainders are collected, which makes the process far easier to do by hand than a full base conversion.

Truth Table and Boolean Expressions

A hardware converter implements the same lookup with logic gates. Treat the decimal inputs \(D_1\) to \(D_9\) as one-hot lines, where a line is high when its digit is present. The truth table then gives one boolean expression per output bit:

$$B_0 = D_1 + D_3 + D_5 + D_7 + D_9,\quad B_1 = D_2 + D_3 + D_6 + D_7$$

$$B_2 = D_4 + D_5 + D_6 + D_7,\quad B_3 = D_8 + D_9$$

Each expression is an OR of the digits whose code has that bit set, so a logic circuit needs just four OR gates. Digital circuits such as keypad encoders use this arrangement.

Worked Example: Converting 6408 to BCD Form

Take the decimal number 6408. It has four digits, so the BCD answer has four nibbles:

Worked Example: Converting 6408 to BCD Form
PositionDecimal digit4-bit BCD group
Thousands60110
Hundreds40100
Tens00000
Units81000

Reading the groups in order gives the BCD equivalent of 6408: 0110 0100 0000 1000. Notice the zero in the tens place still costs a full nibble, because BCD never skips a digit.

Diagram showing the decimal number 6408 split into digits 6, 4, 0 and 8, each mapped to its own 4-bit BCD group
Each digit of 6408 is encoded separately: 0110 0100 0000 1000.

Packed BCD vs Unpacked BCD

Packed BCD stores two digits in each byte, so 6408 fits in two bytes: 01100100 00001000. Unpacked BCD spends one whole byte per digit and leaves the upper four bits at 0000, so the same number takes four bytes: 00000110 00000100 00000000 00001000. Packed form saves memory; unpacked form lets a program handle one digit at a time. A handy side effect of packed storage is that the bytes, read in hexadecimal, spell out the decimal digits as 64 08.

Standard Binary vs BCD Representation

For a binary comparison, convert 6408 the usual way and you get 1100100001000, which needs only 13 bits. The BCD representation takes 16 bits, three more. In exchange, every decimal digit can be located and displayed without any division. With standard binary, you must repeatedly divide by 10 to recover digits, and that costs time on a simple chip.

Bar chart comparing bits needed for 6408: 13 in standard binary, 16 in packed BCD, 32 in unpacked BCD
Storage for 6408: standard binary uses 13 bits, packed BCD 16 and unpacked BCD 32.

BCD to Decimal: Reading a BCD Code Back

To reverse the process, cut the bit string into 4-bit blocks starting from the right, turn each block into its digit and join the digits; any block from 0000 to 1001 is a valid digit. The block 0101 becomes 5, so the string 0101 1001 0011 reads as 593. If any block lands in the unused range, the string is not valid BCD and a careful tool rejects it as an invalid result rather than guessing a digit. Binary values that were not produced by a digit-by-digit encoder will often fail this check.

Loading a Clock Chip Register with a BCD Converter

Dalia, a firmware developer, has a bench prototype that must start its DS3231 real-time clock at 17:42:58. The chip's datasheet says the hours, minutes and seconds registers hold binary coded decimal, so she cannot just write the numbers in plain binary.

She keeps the three values on hand: hours 17, minutes 42 and seconds 58. In the converter she types 17 first, presses the convert button and reads 0001 0111. Then 42 returns 0100 0010, and 58 returns 0101 1000. Packed into bytes, those read as 0x17, 0x42 and 0x58 in hexadecimal, which is exactly the digit pattern she expects to see.

Loading a Clock Chip Register with a BCD Converter
FieldDecimalPacked BCD byteRegister value
Hours170001 01110x17
Minutes420100 00100x42
Seconds580101 10000x58

To see why the shortcut fails, she checks what plain binary would do. Seventeen in standard binary is 10001, or 0x11, and the chip reads that register as 11 hours, six hours off. The hours register also has a 12/24-hour select bit at bit 6, so she confirms that bit stays 0 for 24-hour mode; 0x17 satisfies that because its top three bits are 000.

She writes the three bytes, reads them back and gets 0x17, 0x42, 0x58. As a last check she runs the same bytes backwards through the converter's reverse mode, and the digits return as 17, 42 and 58, so the clock starts at the right time.

BCD Addition and BCD Subtraction with a Correction Factor

Once the converter turns 38 and 29 into 0011 1000 and 0010 1001, the next question is what happens when you add them. BCD addition works like normal binary addition on each nibble, followed by one repair step. If a nibble sum exceeds 1001 (9) or produces a carry out, you add the correction factor 0110 (6) to skip the six unused patterns. Add 38 and 29: the low nibbles give 1000 + 1001 = 1 0001, a carry, so 0110 is added to give 0111 with the carry moving left. The upper nibbles give 0011 + 0010 + 1 = 0110. The final BCD code is 0110 0111, which is 67.

For BCD subtraction, a borrow forces the same adjustment in reverse. Take 91 minus 36: the low nibble 0001 minus 0110 borrows and leaves 1011, an invalid digit, so subtract 0110 to get 0101. The upper nibble becomes 1001 minus 0011 minus the borrow, which is 0101. The result is 0101 0101, or 55. This kind of decimal arithmetic is exactly what calculators and cash registers rely on.

Waterfall chart of BCD addition 38 plus 29: binary sum 61, plus the 6 correction factor, equals 67
The correction factor of 6 turns the raw sum 61 into the valid BCD sum 67.

Free BCD Converter Uses: Displays, Finance and Legacy Systems

A free BCD converter is more than a classroom aid, because the format solves real engineering problems:

  • Seven-segment displays: a decoder chip turns each nibble directly into the lit segments, so no division is needed to show a number.
  • Digital clocks and counters: hours and minutes are kept as separate digits, which suits embedded systems with tiny processors.
  • Financial and monetary calculations: values such as 0.10 cannot be stored exactly in IEEE-754 floating-point form, but BCD holds every decimal digit with no rounding errors, and fixed point numbers work well with it.
  • Legacy systems and instruments: older mainframes, meters and microcontrollers keep dates and quantities in BCD, so a programmer who maintains them needs to read it fluently.

The trade-off is memory and speed. Because of the unused bit patterns, BCD stores less information per bit, and hardware that adds with a correction factor is slower than plain binary logic. To place a decimal point, designers either reserve a pseudotetrade or fix the number of places before and after it.

Excess-3, Gray Code and ASCII: Related Code Converters

BCD is one of several digital systems codes you will meet in computer science. Excess-3 adds 3 to every digit before encoding, which makes the code self-complementing and helpful in older arithmetic hardware. Gray code changes only one bit between neighbouring values, so it suits position sensors. ASCII assigns a byte to each text character, including the digits 0 to 9, so a number typed on a keyboard is a string of ASCII characters before any code converters turn it into BCD. Other tools deal with octal and hexadecimal, which regroup plain binary rather than digits: an octal digit covers three binary places and a hexadecimal digit covers four, and a parity bit can be added to any of them to detect single-bit errors. Knowing which one to choose keeps your accuracy high when you move data between number systems.