Storing and retrieving
kha at treskal.com
Sat Jul 2 11:48:41 CEST 2005
On 2005-07-02 03:53:52 +0000, mrgrynch at comcast.net 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:
seem to be any such functions dealing with mpfs, though.
Formatted output in base 16 or 32 should be the second best thing.
http://swox.com/gmp/manual/C---Formatted-Input.html 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 treskal.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: Digital signature
Url : http://gmplib.org/list-archives/gmp-discuss/attachments/20050702/9c1d1c44/attachment.bin
More information about the gmp-discuss