go ahead... be a heretic | |
PerlMonks |
Re: Compress positive integersby ikegami (Patriarch) |
on Apr 07, 2008 at 23:08 UTC ( [id://678854]=note: print w/replies, xml ) | Need Help?? |
For starters, you'd get better compressing using one of the numerous compression modules on CPAN. (Some sample queries: Compress, gzip, zip) The technique used by the code you posted is useful to save space on disk when dealing with lots of small numbers. It takes fewer bytes to save small numbers, and an extra byte to save very large numbers. It's advantage over general purpose compression algorithms is that you can seek to known and unknown positions into the file.
Depending on the size of the ints on your system and the precision of floats on your system, some of the above aren't available or more than the above is available. Untested:
Update: Fixed some typos in text and code.
In Section
Seekers of Perl Wisdom
|
|