Storing and retrieving

Karl Hasselström kha at
Sat Jul 2 11:48:41 CEST 2005

On 2005-07-02 03:53:52 +0000, mrgrynch at wrote:

> I have a need to preserve a bunch of GMP floating point values (from
> an array of mpf_class objects) for retrieval at a later time. The
> experiement I am running will take about a year, and I'd hate to
> lose it all if the power goes out, etc...
> I was thinking the easiest way to do this is with strings. Has
> anyone done this before? Reading through the documentation, I'm not
> entirely sure about the argument list to be passed to the functions
> which handle this, nor how they would work through the C++ class
> interface, which I am using. Would I have to extract a reference to
> the underlying C structure before converting to and from strings?

Hmm. For integers, there are nice binary I/O functions: Doesn't
seem to be any such functions dealing with mpfs, though.

Formatted output in base 16 or 32 should be the second best thing. and explain how to do
formatted IO of mpfs. If they can't give you sufficient control of the
output format (I don't know if they do -- they seem to use the usual
C++ way of controlling such things, and I haven't touched C++ in
years), you can always use the C formatted IO functions -- again, see
the manual (the very first section in the C++ chapter explains how to
get mpf_t values out of mpf_class values).

Karl Hasselström, kha at
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url :

More information about the gmp-discuss mailing list