lesson

Updated 1 month ago Β· 7 views
Have you ever wondered why your microwave clock never glitches when stepping from 09 seconds to 10 seconds, even though computer chips naturally count in powers of 2?
Instead of treating a multi-digit number as one giant binary value, digital displays often use Binary Coded Decimal (BCD) to encode every base-10 digit into its own 4-bit binary chunk.
What happens when binary patterns produce values larger than 9 that don't correspond to any single decimal digit?
The Anatomy of BCD and Invalid States
In standard 8421 BCD, each decimal digit from 0 to 9 is represented by an independent 4-bit binary group (called a nibble).
Since 4 bits can create 24=16 unique combinations (00002β to 11112β), the patterns from 10102β (1010β) through 11112β (1510β) are strictly invalid states in BCD.
πInteractive diagram
How do we convert a large multi-digit decimal number into BCD?
Decimal to BCD Conversion
To convert from decimal (denary) to BCD, write each decimal digit as its own 4-bit binary nibble, preserving all leading zeros within each nibble.
Let's convert 39510β into BCD: convert 3ightarrow00112β, 9ightarrow10012β, and 5ightarrow01012β to get 0011Β 1001Β 0101BCDβ.
πInteractive diagram
To convert backwards from BCD to decimal, split the bitstream into groups of 4 from right to left, verify that none are invalid states, and translate each nibble to a base-10 digit.