Re: A85: Chem program


[Prev][Next][Index][Thread]

Re: A85: Chem program




Justin,

Here is my compression method for the atomic masses.  Actually this is not a true form of
compression, it is more of a specialized case of it.  What you do is you use the elements' atomic
number as a starting number.  You then create a table of two byte words which contain the
compressed atomic masses.  This is how they are compressed.You start
out with a number derived from this formula: 2n+n/2+n/8-17 (asm friendly, otherwise it's
2.605x-16.897 using linear regression to calculate it, but that equation fits just as well.) where
n is the atomic number.  Then you store what you add to this number in the table.  It turns out
that all of the numbers are between 0 and 16.383 (the largest 14 bit number, with the decimal
shifted left 3 places:  2^14=16,384) except for A.N.'s 98,108, and 109.  These three can be
special cased with cmp's and jr's.  Of course, you still have two bits left over, but these can
easily store anything, perhaps the type of element - metal, nonmetal, metalloid, or gas.  Just try
to use every bit to its maximum potential.

To store the names, you can either store them as length terminated (one less bit than 0
terminated, but max. 16 chars.  I don't think there are elements with more than that) strings with
5 bits instead of 8 for the characters and a 7 bit atomic number at the end to search the mass
table described above.  Otherwise, you could have a flag at the beginning of the string to tell
whether it is 5 bit or 4 bit letters, and if it is 4 bit, you would store the first letter in 5
bits, and the next as 4 bit offsets from that letter.  Obviously this would only work for some of
the elements, but it could save some space.  This way would take longer to extract, and would
possibly slow down a search process.  Of course, if you converted the element you were searching
for into this form, it would not take as long, and would possibly be faster than searching a
regular string.

If any of this did not make sense, feel free to write me back, and I will send a more detailed
explanation.

Hope this was helpful,
Dave

Justin M Bosch wrote:

> I have decided to either make a few ROM dependent versions, or one
> version that supports the two or three most popular ROMs.  A lot of
> people I know have 10.0, so that will definitely be one of the ones
> supported.  If anyone would like to request another ROM version, I am
> open to suggestions.  I might be able to release beta copies with limited
> functionality in a week or two, depending on my work load in school.
> These will not yet include the molar mass calculator, and thus be ROM
> indepependent since they will not use the OP routines.  If anyone has any
> suggestions on how to compress all of the elemental data, please assist
> me because I have no compression experience.
>
> Justin Bosch
> justin-b@juno.com
>
> ___________________________________________________________________
> You don't need to buy Internet access to use free Internet e-mail.
> Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
> or call Juno at (800) 654-JUNO [654-5866]



References: