views:

46

answers:

1

It seems that GMP provides only string serialization of the mpf (floating point) type:

mpf_get_str(), mpf_class::get_str()

The mpz (integer) type has an additional interface for raw bytes: mpz_out_raw()

http://gmplib.org/manual/Function-Index.html

Am I missing something? Does anyone know of another library that can serialize GMP floats? Does anyone know of another bignum lib that offers robust serialization?

Edit: I'd be happy with serializing MPFR's mpfr_t, as well, which similarly only seems to offer string output: http://www.mpfr.org/mpfr-current/mpfr.html#Function-Index

+1  A: 

You can do input and output of the bytes in GMP floats. The manual page on I/O of Floats lists the following functions:

size_t mpf_out_str (FILE *stream, int base, size_t n_digits, mpf_t op)
size_t mpf_inp_str (mpf_t rop, FILE *stream, int base)

The confusing part about the manual is that it lists the I/O routines for the different types in different sections.

Edit: I was totally wrong! These functions are doing string conversion, not outputting the raw bytes.

Bkkbrad