23.8k views
4 votes
How do I convert BCD to denary and denary to BCD? (For Both positive and Negative integer of denary)

User Hojun
by
5.9k points

1 Answer

2 votes

Answer:

BCD is very similar to regular binary code. Decimal digits are represented as binary like so:

0 = 0000

1 = 0001

2 = 0010

3 = 0011

etc...

9 = 1001

However, in BCD the structure of decimal code is maintained, so e.g., the number 123 would be encoded digit-by-digit as:

0001 0010 0011

whereas in pure binary it would be encoded as

01111011

So you immediately see that BCD is not so efficient. That's why it is not used very often. Encoding and decoding is very easy as you take the same approach as with pure binary, but perform it per digit (ie., per group of 4 bits).

User Jflinter
by
5.4k points