mpz_out_raw limitation ?

tom at tom at
Sun Sep 4 21:47:59 CEST 2011

Hello dear list,

looking at the mpz_out_raw, I am wondering if there is a limitation there
that could be lifted. The current format for a file saving a numbers is:

4 bytes to store the size (in number of bytes) of the number
x bytes to store the number itself.

Now this 'only' provides at best 2Gb max for the file size, that's how
much 4 bytes would allow. There are some important compatibility issues at
stake but it seems that a size-independent format would be useful.

Let me know if I am missing something but if not, here are my 2 cents for
such a format:

- x bits at 1 terminated by 0's (until the end of the current byte)
indicating the amount of bytes the size of the number will be defined
- x bytes indicating the size of the number to store
- y bytes to store the number itself.

I left the endianess alone to express the main idea but if there is
interest in the suggestion I could implement it. What do you all think
about this? Crazy,stupid,why not, other?

More information about the gmp-discuss mailing list