Tuesday, April 23, 2019

TWO OUT OF EVERY FIVE AGREE...

TWO OUT OF EVERY FIVE AGREE...
Converting a binary number into a Decimal Number is confusing.
Seems simple enough.


16 8  4  2  1   <--- The weights of the bits in a Binary Coded Decimal number (BCD)
 1  0  0  0  1    To find the decimal value just add up the weights of all the "1" bits.

So, to convert 10001 BCD to decimal, we just add 16 + 1 and get 17 decimal

To be more exact, we just converted a Binary Coded Decimal  (BCD) number to decimal.
However, BCD isn't the only way of coding a binary number.

Consider 2 of 5 binary numbers. The weight of each column is different from regular BCD.

 6  3  2  1  0     The weights of the bits in a 2 of 5 coded binary number (2 of 5)
 1  0  0  0  1      Again, we just add up the weights of the "1" bits.
                         So 6 + 0 = 6
In 2 of 5, we always have 5 bits and two of them are "1"s while the others are "0"s

Here is the complete list:


6 3 2 1 0 <--- The weights of the bits in a Binary Coded Decimal number (BCD)
0 0 0 1 1     1 + 0 = 1
0 0 1 0 1     2 + 0 = 2
0 1 0 0 1     3 + 0 = 3
0 1 0 1 0     3 + 1 = 4
0 1 1 0 0     3 + 2 = 5
1 0 0 0 1     6 + 0 = 6
1 0 0 1 0     6 + 1 = 7
1 0 1 0 0     6 + 2 = 8
1 1 0 0 0     6 + 3 = 9
0 0 1 1 0    2 + 1 =  0  (there are two ways to form "3", so this combination is taken to be zero.)

Notice that there is no way to combine two "1"s and three zeros to represent a decimal zero. Yet, there are two ways to convert a decimal 3 to two of five binary,

6 3 2 1 0  <--- The weights
0 1 0 0 1     3 + 0 = 3
0 0 1 1 0     2 + 1 =  3 

No comments:

Post a Comment