Compression that can be used with mpz_*_raw

Paul Leyland pleyland at
Thu May 13 16:31:38 CEST 2004

Try zlib (  It may, or may not, do what you
want so ensure you validate it for your purposes before investing a
lot of effort.

I make no guarantees whatsoever that it's of any use
for anything.  How's that for derriere covering?


> -----Original Message-----
> From: gmp-discuss-bounces at 
> [mailto:gmp-discuss-bounces at] On Behalf Of David McKen
> Sent: 13 May 2004 15:04
> To: GMP Mailing list
> Subject: Compression that can be used with mpz_*_raw
> 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
> normally?
> 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'
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss at

More information about the gmp-discuss mailing list