ForHosting KIT · Developer Utilities

BCD to binary converter

This BCD to binary converter decodes a packed 8421 binary-coded decimal value into both its familiar decimal form and its ordinary base-two representation.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

It checks the input nibble by nibble, so bit groups from 1010 through 1111 are reported as invalid instead of becoming misleading numbers. Readable separators and an optional 0b prefix are accepted, while string-based results preserve exact values well beyond the safe integer range of JavaScript numbers.

Understand what packed BCD represents

Packed 8421 binary-coded decimal is not the same representation as an ordinary binary integer. In BCD, every decimal digit receives its own four-bit nibble: decimal 2 becomes 0010, 5 becomes 0101, and 9 becomes 1001. Consequently, the decimal number 259 is written as 0010 0101 1001. Reading that entire bit sequence as an ordinary base-two number would produce a different value, because normal binary uses powers of two across the complete word rather than restarting the 8-4-2-1 weights for each decimal digit. This converter performs the necessary two-stage interpretation. It first validates and decodes each nibble to recover the decimal digit sequence, then converts that exact decimal integer to its plain binary representation. The response includes the normalized packed BCD bits, the decimal result, the binary result, and the number of BCD digits, making each stage visible for lessons, circuit checks, and automated tests.

Enter and validate the bit groups

Supply one or more complete four-bit groups in the bcd field. You may write the bits continuously, separate nibbles with spaces, underscores, or hyphens, and optionally begin the value with 0b. Separators are removed before validation, so 0010 0101 1001 and 0b0010_0101_1001 describe the same packed value. Every remaining character must be zero or one, and the total bit count must be divisible by four. More importantly, each nibble must fall between 0000 and 1001. Patterns 1010 through 1111 exist as binary values but are not legal decimal digits in standard 8421 BCD, so the converter rejects them with a precise position instead of silently accepting corrupted data. Leading zero digits are accepted and retained in the normalized BCD field, while the decimal and ordinary binary outputs are canonicalized. For example, BCD 0000 0101 yields decimal 5 and binary 101, without losing the original two-nibble encoding from the bcd result.

Use exact results in digital arithmetic workflows

The decimal and binary results are returned as strings deliberately. Packed display registers, financial devices, counters, and test vectors can contain more digits than a JavaScript Number can represent exactly. Converting through floating-point arithmetic could round a large identifier or measurement before it reaches the next stage. This implementation builds the decimal digit sequence directly, converts it with exact integer arithmetic, and supports up to the published limit without network access, randomness, or time-dependent behavior. That makes repeated calls deterministic and safe to compare in a golden test. In a hardware workflow, use the normalized bcd value to confirm what was received, the decimal value for operator-facing logs, and the binary value for arithmetic units or register sizing. Remember that this tool decodes unsigned packed 8421 BCD only. It does not infer sign nibbles, unpacked character encodings, excess-3 code, densely packed decimal, or vendor-specific flag bits. Remove or interpret those protocol fields before sending the digit nibbles here.

Check a BCD register dump

Decode grouped register bits into decimal for inspection and ordinary binary for downstream arithmetic.

Validate digital logic exercises

Confirm that every proposed BCD nibble is legal and compare the decoded value with its base-two form.

Normalize test vectors

Turn readable BCD fixtures with separators into stable decimal, binary, and compact BCD strings for assertions.

What does one conversion cost?

Each API item costs $0.002; the browser version can run locally for free.

Why is BCD different from ordinary binary?

BCD encodes each decimal digit independently in four bits, while ordinary binary assigns powers of two across the entire value.

Which BCD format is supported?

The converter supports unsigned packed 8421 BCD with one decimal digit per four-bit nibble.

Why are 1010 through 1111 rejected?

Those nibble values represent 10 through 15 in binary, but a BCD nibble may represent only decimal digits 0 through 9.

Can I include spaces or a 0b prefix?

Yes. Spaces, underscores, hyphens, and one leading 0b prefix are accepted and removed during normalization.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/elec/bcd-to-binary

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/elec/bcd-to-binary \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"bcd":"0010 0101 1001"}'
{
  "bcd": "0010 0101 1001"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "elec.bcd_to_binary",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_digits256
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →