A question about mpz_out_str and mpz_out_raw output limitation

Torbjörn Granlund tg at gmplib.org
Wed Jun 25 13:22:23 UTC 2014


David Gillies <daggillies at gmail.com> writes:

  Forgot about sign of size bit. Presumably the inability to fully represent
  the 2^37 bit values available in 64-bit code is a legacy issue from the
  days when 2GB mpz_t's were infeasibly large. Perhaps a trivial extension
  (which would break portability, alas) would be to prepend a single byte
  indicating the length of the size header. In addition, mpz_out_raw
  allocates a temporary roughly as big as the integer before writing to file.
  I can see this causing problems.

I am not sure we need to supply improved raw functions, given that the
export/import function allow almost the same functionality.  The main
difference is that users need to write some size information when using
export/import.

(Perhaps we should make the raw functions call export/import; that would
avoid the large allocation you mention.  It would also avoid some code
duplication.)


Torbjörn
Please encrypt, key id 0xC8601622


More information about the gmp-discuss mailing list