Binary-coded decimal (BCD) is a way to represent decimal digits in binary: 00002-10012 corresponds to 0d-9d. The subscripts "2" and "d" mean binary and decimal, respectively. In the process, we chuck away 10102-11112, the remaining six values that we can encode in a nibble  ─ the actual name for a 4-bit word! Turns out that what we’ve described as "BCD" should more accurately be identified as Natural or Simple or 8421 BCD because it is only one of many BCD flavors. In fact,  there are over 30 other ways to slice the nibble into a BCD encoding!

BCD encoding has advantages in some applications and was used quite extensively in the early days of digital processing. You can still see modern microcontrollers output BCD because, for example, it’s easier to display on a seven-segment display compared to the additional logic required if the output was in binary. Each flavor of BCD was developed with a subtle advantage for a particular application, like a symmetry property or the location of particular bits. Most of those applications are not all that relevant anymore, however.

A few of the many encoding flavors are shown in the table below where the numbers in the header are the weights of the bits, which can also be negative. So 8d in  63-2-1 encoding is 1101b (1x6 + 1x3 + 0x(-2)+ 1x(-1)), although 0, 3, and 6 can be encoded in two different ways!
 


But there’s more. Those states that aren’t used in Natural BCD are sometimes used to indicate if the number is negative or positive; those are called Packed BCD. The 3GPP developed Telephony BCD where unused characters are packed with characters from a common keypad. And, BCD was part of a landmark 1970s ruling by the US Supreme Court that enforced the restriction that algorithms and mathematical expressions could not be patented. (Gary Benson and Arthur Tabbot tried to patent an algorithm for converting BCD into binary.)

Wikipedia has much more about the flavors of BCD. I’m writing all this to share the excitement of discovering the hidden subtle tastes of BCD, and also to enable you and I to say “Oh, you mean Natural BCD…” with a knowledgeable grin.
 


Additional Circuit Shorts, Info on BCD, and More

Interested in circuit design,BCD, and related topics? Subscribe to the "Circuit Shorts" tag to receive updates when new content is published. If you need a rapid prototyping solution, check out ElektorPCB4Makers. Get two PCB prototypes in three working days!