Compression that can be used with mpz_*_raw

David McKen cic_3_b at
Thu May 13 16:03:30 CEST 2004

Ok, I have a program that writes a bunch of numbers to a file (the
numbers are aprox 300 digits long). 

Putting 1,000,000 of them in a file with mpz_out_raw gives me a 129Mb
file, which needless to say is kinda big.

Just on a hunch I decided to try compressing the file. The results
were quite impressive, .zip (Microsoft's built in compressor, Yikes)
- 1.5Mb, .bz2 (win32 command line bin util I found online) - 553Kb, I
didn't try .gz experience has shown me that it usually falls right
between bz2 and zip. This is great! I can store and transport the
numbers easily, one problem though. When I want to do something with
said numbers do I have to de-compress the entire file and open it

Essentially it boils down to, Does anyone know a compression library
that can work well with GMP? I know of a C++ zip stream library but
the mpz_*_raw functions use a FILE * which kinda makes it hard to put
a man in the middle. This brings up another question, are the
mpz_*_raw functions accessible through the C++ interface? From what I
can tell they are not.

I have considered spliting the file so each individual file is
smaller and just have more of them but that brings a problem with
both .gz and .bz2, I would have to use a tar archive as well which
would require that I still de-compress the entire tar archive and
then access the files I want. Luckily this does not knock out zip but
I would prefer the better compression.

Thanks in Advance
David McKen

Do you Yahoo!?
Yahoo! Movies - Buy advance tickets for 'Shrek 2' 

More information about the gmp-discuss mailing list