<html><body>
<DIV>
<DIV> </DIV>
<DIV>Thanks for the information! I am currently already using the C++ wrappers that come with GMP. So far, I've wirtten the code to stream these text values to a file. The question arises when I read them back...</DIV>
<DIV> </DIV>
<DIV>Can I just read the value in and set an mpf_class to that string value, and be comfortable that the conversion will work? The documentation for this is a bit confusing for me, as it says...</DIV>
<DIV> </DIV>
<DIV><FONT face=CMTT10~8b>
<P align=left>int mpf_set_str </FONT><FONT face=CMSS10 size=3>(</FONT><FONT face=CMSL10 size=3>mpf t </FONT><FONT face=CMSLTT10>rop</FONT><FONT face=CMSL10 size=3>, char *</FONT><FONT face=CMSLTT10>str</FONT><FONT face=CMSL10 size=3>, int </FONT><FONT face=CMSLTT10>base</FONT><FONT face=CMSS10 size=3>) </FONT><FONT face=CMR10 size=3>[Function]</P>
<P align=left>Set the value of </FONT><FONT face=CMSL10 size=3>rop </FONT><FONT face=CMR10 size=3>from the string in </FONT><FONT face=CMSL10 size=3>str</FONT><FONT face=CMR10 size=3>. The string is of the form `</FONT><FONT face=CMTT10 size=3>M@N</FONT><FONT face=CMR10 size=3>' or...., if the base is 10 or less, alternatively `</FONT><FONT face=CMTT10 size=3>MeN</FONT><FONT face=CMR10 size=3>'.</FONT></P>
<P align=left><FONT face=CMTT10 size=3>Assuming I am using base 10, then I believe what this means is I can just call this method with a number like "-3.17335744356735673e-14", and it will properly set the destination object to that value, assuming a suitable precision level of the destination structure. </FONT></P></DIV></DIV>
<DIV>Am I correct in this? If I am, then I think I've all I need to do what I need.</DIV>
<DIV> -Dave</DIV>
<DIV> </DIV>
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">-------------- Original message -------------- <BR><BR>> At 03:53 +0000 2005/07/02, mrgrynch@comcast.net wrote: <BR>> >I have a need to preserve a bunch of GMP floating point values (from <BR>> >an array of mpf_class objects) for retrieval at a later time. The <BR>> >experiement I am running will take about a year, and I'd hate to <BR>> >lose it all if the power goes out, etc... <BR>> > <BR>> > I was thinking the easiest way to do this is with strings. Has <BR>> >anyone done this before? <BR>> <BR>> One can write binary data to a file and read it back, but I gather if <BR>> the core parts that the GMP relies on would somehow change, it would <BR>> make the file binary data unreadable. So the safest way, though <BR>> slower, is to write it out as text, and read it back again. You are <BR>> then embarking, in its extension, on the path of making two programs, <BR>> a parser that can read this kind of data, and an expresser, or <BR>> "pretty-printer", that can write out it. Ultimately, if you develop a <BR>> computer language, you may need the use of tools such as the lexer <BR>> generator Flex and the parser generator Bison. <BR>> <BR>> But start simply, expand at need. <BR>> <BR>> >Reading through the documentation, I'm not entirely sure about the <BR>> >argument list to be passed to the functions which handle this, nor <BR>> >how they would work through the C++ class interface, which I am <BR>> >using. Would I have to extract a reference to the underlying C <BR>> >structure before converting to and from strings? <BR>> <BR>> GMP has C read and write functions, and further, some C++ support. I <BR>> haven't used the latter, as I wrote my own C++ wrap. I can send it to <BR>> you by private mail, if you so like. <BR>> <BR>> The major drawback of my C++ wrap is that I had my own version of the <BR>> GMP read function. So it means that if GMP changes that, I will have <BR>> to do some rewriting. But this part is there only to make a C++ nice <BR>> istream interface; you could use something more version-stable, if <BR>> you like. Otherwise, it is just a C++ interface on top of C, using <BR>> reference counts to avoid unneeded recopying. <BR>> -- <BR>> Hans Aberg </BLOCKQUOTE></body></html>