User Rating 0.0 β˜…β˜…β˜…β˜…β˜…
Total Usage 0 times
0 bits
Is this tool helpful?

Your feedback helps us improve.

β˜… β˜… β˜… β˜… β˜…

About

Binary-Coded Decimal (BCD) maps each decimal digit to a fixed-length 4-bit binary nibble using the 8421 weighting scheme. The encoding is not equivalent to standard positional binary. A raw binary value 1111 represents decimal 15, but in BCD the nibble 1111 is invalid because only patterns 0000 - 1001 (decimal 0 - 9) are legal. Confusing the two encodings in hardware registers, PLC communications, or financial arithmetic causes silent data corruption. This tool converts between pure binary and 8421 BCD for arbitrary-length integers, validates every nibble, and flags illegal codes immediately.

BCD remains critical in digital clocks, calculators, SCADA displays, and any system where decimal rounding errors are unacceptable. The 8421 variant is specified in IEEE 754-2008 for decimal floating-point and in IEC 60044 metering standards. Note: this converter handles unsigned integers only. Signed BCD representations (tens’ complement, sign nibble) require additional protocol knowledge beyond this tool’s scope.

binary to bcd bcd converter binary coded decimal 8421 bcd number system converter binary converter

Formulas

The 8421 BCD encoding converts a decimal integer N into a sequence of 4-bit nibbles, one per decimal digit.

Binary β†’ BCD conversion:

Step 1. Parse the binary string to obtain decimal value N:

N = nβˆ’1βˆ‘i=0 bi β‹… 2i

Step 2. Extract each decimal digit dk via repeated division:

dk = N mod 10, N ← N10

Step 3. Encode each digit dk ∈ {0, 1, …, 9} as its 4-bit binary representation.

BCD β†’ Binary conversion:

Step 1. Split BCD string into 4-bit nibbles (pad with leading zeros if length is not a multiple of 4).

Step 2. Validate each nibble: dk ≀ 9. If dk β‰₯ 10, the nibble 1010 - 1111 is an illegal BCD code.

Step 3. Reconstruct decimal: N = mβˆ’1βˆ‘k=0 dk β‹… 10k

Step 4. Convert N to binary: N.toString(2).

Where bi = the i-th bit of the binary input, n = total bit count, dk = the k-th decimal digit (least-significant first), and m = number of BCD nibbles.

Reference Data

Decimal DigitBCD (8421)Binary Value of NibbleExcess-3 BCDGray Code
00000000110000
10001101000001
20010201010011
30011301100010
40100401110110
50101510000111
60110610010101
70111710100100
81000810111100
91001911001101
Nibbles 1010 - 1111 are invalid in 8421 BCD
100001 00001010 (binary)0100 0011 -
420100 0010101010 (binary)0111 0101 -
991001 10011100011 (binary)1100 1100 -
1000001 0000 00001100100 (binary)0100 0011 0011 -
2550010 0101 010111111111 (binary)0101 1000 1000 -
10000001 0000 0000 00001111101000 (binary)0100 0011 0011 0011 -
99991001 1001 1001 100110011100001111 (binary)1100 1100 1100 1100 -

Frequently Asked Questions

In 8421 BCD, each 4-bit nibble represents exactly one decimal digit (0-9). The nibble values 1010 (10) through 1111 (15) have no single-digit decimal equivalent. Hardware decoders treat these as error conditions. Some legacy systems use 1010-1111 as control codes (e.g., sign indicators in packed BCD), but standard 8421 BCD rejects them.
Standard binary encodes the entire number as one positional value. BCD encodes each decimal digit independently. For example, decimal 25 in binary is 11001 (5 bits). In BCD it is 0010 0101 (8 bits). BCD always uses more bits but preserves decimal digit boundaries, which prevents rounding errors in decimal arithmetic.
The converter uses JavaScript BigInt internally, which supports arbitrary-precision integers. Practical limits depend on browser memory. Inputs of several thousand bits convert without issue. For extremely long inputs (millions of bits), expect proportional processing time due to BigInt division operations.
No. This converter handles unsigned integers only. BCD encoding for fractional parts requires fixed-point conventions (e.g., specifying the number of digits after the decimal point), which vary by application. The tool will reject any input containing characters other than 0 and 1.
BCD appears in real-time clocks (DS1307, DS3231), financial computing (IBM System z decimal instructions), SCADA/HMI panel displays, utility meters (IEC 62056), and USB HID device descriptors. IEEE 754-2008 specifies densely packed decimal (DPD) as a compressed BCD variant for decimal floating-point.
The converter automatically pads the input with leading zeros to form complete 4-bit nibbles. For example, an input of 110 becomes 0110, which decodes to decimal 6. This matches standard BCD convention where the most-significant nibble may have implicit leading zeros.