Subject: | |
From: | |
Reply To: | |
Date: | Fri, 25 Feb 2000 16:42:34 -0800 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Re:
> What is the algorithm to fit an all upper class alphanumeric field of 25
> characters to a field of 12 characters. So I could print barcode from the
> new field. Your help and advice will be appreciated.
(assuming "upper case", not "upper class")
Alphanumeric means you have 36 possible characters ... it takes a little more
than 5 bits to represent 36 choices. (So, we'll round up to 6 bits)
A simple analysis says you have 25 * 6 bits of data ... which is 150 bits.
Now, by "to a field of 12 characters", I assume you mean that the output
has to fit into 12 8-bit bytes (with no restrictions on what can be in those
bytes). But, 12 bytes * 8 bits/byte is only 96 bits.
Hmm...simple packing isn't going to work! (Even if you used exactly 5
bits per char, 5 * 25 = 125 bits, which is still more than 96 bits!)
I.e., the first answer is: compression.
The second answer is: you can not compress every possible input
of 25 uppercase alphanumeric characters down to 12 bytes ... so plan on handling
that contingency!
(Proof: there are 36**25 possible input combinations, which is a lot more
than 256**12 possible output combinations)
According to the calculator in QEDIT:
36**25 = .808281277465E+39
256**12 = .792281625143E+29
Of course, you may know something about this 25 characters ... perhaps
they're highly compressible.
Good luck,
SS
Stan Sieler [log in to unmask]
www.allegro.com/sieler/wanted/index.html www.allegro.com/sieler
|
|
|