Force # of data bytes in raw integer format, and omit size information?

Paul Zimmermann Paul.Zimmermann at loria.fr
Mon Feb 23 09:23:10 CET 2009


> I'm writing large numbers of raw GMP integers to index files.
> The numbers currently range from 0 to about 10^25.
> 
> I started out using mpz_out_raw. If a number has less than the
> maximum # of data bytes, after writing the number, I pad (with
> empty bytes) to give a constant record size. That lets me do
> binary searches on the index files (fseek, mpz_inp_raw).

since 10^25 needs 11 bytes, I suggest you store your numbers in separate files
for 0, 1, 2, ..., 11 bytes. Then no padding is necessary in each file.

Paul Zimmermann


More information about the gmp-discuss mailing list