BCD 1001 0111 → decimal

introdecode each nibble separately

Answer

97

Why this example is worth doing

Decoding is per-nibble and never across the whole word: 1001 is nine and 0111 is seven, so the value is ninety-seven. Read as ordinary binary the same bits are one hundred and fifty-one, and the page shows both to make the point that a bit pattern means nothing without a declared encoding. That is the same lesson as the two's complement width question, arriving from a different direction.

Try your own input in the BCD converter. Pack and unpack binary-coded decimal, and add with the +6 correction shown.

How the answer is reached

Decode packed BCD 10010111

Decode packed BCD 10010111 — columns group, bits, digit
groupbitsdigit
010019
101117

value97

Compare with

Open the BCD converter

This input is entered in the tool itself — it is too rich for a link to carry.

Note:

Notation this page assumes

  • Bit strings are written most significant bit first, and bit 0 is the least significant bit.
  • A width is stated explicitly wherever it changes the answer; nothing is silently sign-extended or truncated.
  • Fractions are converted digit by digit and shown to a stated number of places rather than rounded silently.

Sources

  • Knuth, The Art of Computer Programming, Vol. 2, §4.1 “Positional Number Systems” (1997)
  • ANSI X3.4 / ISO-IEC 646, the ASCII character set