
The current default situation is to print just 5 digits, and that certainly doesn't get close!
Hmmm - that surprises me. I look at the code in the file basic_text_oprimitive.hpp and I find:
void save(const float t) { // must be a user mistake - can't serialize un-initialized data if(os.fail()) boost::serialization::throw_exception( archive_exception(archive_exception::output_stream_error) ); os << std::setprecision(std::numeric_limits<float>::digits10 + 2); os << t; }
Is this code not correct? Note that I added in 2 extra digits. Or is this code not getting invoked? Let me know.
Ah... my problem was with a UDT that was marked as a primitive: then it just calls the << operator and doesn't attempt to set the stream precision as far as I can tell? The issue would presumably also surface if someone tried to non-intrusively support non-standard native floating point types such as GCC's __float128 or Intel's _Quad data types, you can write a "serialize" function instead, but as you already pointed out, that involves more typing once you you split the method into load/save and binary/text variants. John.