Associated Topics || Dr. Math Home || Search Dr. Math

### 2421 Decimal Code

```Date: 11/08/2004 at 04:23:28
From: Dibyendu
Subject: 2421 decimal code

Can you explain why some bit combinations for 2421 are invalid?  For
example, to represent decimal 5 (five) in 2421, the correct code is
1011.  But why can't we represent decimal 5 in 2421 as 0101, because
if we add the weights as 0*2 + 1*4 + 0*2 + 1*1, we get 5 in decimal.

The most confusing part is that some decimal numbers can have multiple
representations in 2421 but only one among them is treated as a valid
code.  Why?

```

```
Date: 11/08/2004 at 11:56:50
From: Doctor Cristian
Subject: Re: 2421 decimal code

Hi Dibyendu, and thanks for writing to Dr. Math!

I found the table of the 2421 representation of digits by searching
the Internet for these keywords:

2421 decimal code

It goes as follows:

base-10 | 2421-code
0    |  0000
1    |  0001
2    |  0010
3    |  0011
4    |  0100
|
5    |  1011
6    |  1100
7    |  1101
8    |  1110
9    |  1111

It seems to me that when the code was invented, they wanted an x421
code that can start at 0000 and end at 1111 (which determines the
value of x: x = 9 - 4 - 2 - 1 = 2). The halves would be easy to
divide: the first five digits start with 0, the last five digits start
with 1.

So all you need to remember to work with 2421 code is to name it H421:
the first digit represents the half in which the digit belongs.  The
next three digits are the standard representation (in 421) of what's
left to transform: n - (2 * first_digit).

In fact, all the digits between 2 and 7 (inclusive) have multiple
representations in 2421, but that doesn't stop anyone from passing the
2421 code along.  :^D

Does this help?

- Doctor Cristian, The Math Forum
http://mathforum.org/dr.math/

```

```
Date: 11/09/2004 at 09:14:01
From: Dibyendu
Subject: Thank you (2421 decimal code)

Thank you so much.  Keep up the good work.
```
Associated Topics: