Peteroid wrote:
What is the value for 'setprecision' that will cause doubles to be saved
'perfectly' (i.e., what goes in comes out with the EXACT same value)? Or,
what can I do to accomplish this if 'setprecision' is not the way to go?
If the data is to be read on the same platform and executable that it
was written out with, you can use a simple binary write:
os.write(reinterpret_cast<char*>(&adouble), sizeof adouble);
and to read it:
is.read(reinterpret_cast<char*>(&adouble), sizeof adouble);
Remember to use std::ios_base::binary when opening the streams!
If you need the format to be portable in any way, you'll have to use a
portable binary format which will involve a bit more work to assemble
and disassemble your doubles to the stream.
Tom