Boost.Serialization vs STL containers of 'double'

Hi, I am using Boost.Serialization to serialize a std::map<std::string, double>. It works fine, except that the precision on the double is not enough for my application. Is it possible to manipulate the precision used when serializing/deserializing double's within an STL container? I tried using setprecision(), but it doesn't understand the "&" stream operator that the Serialization library uses. Thanks, Adam

The precision is set in basic_text_oprimitive.hpp line 139. with the statement: os << std::setprecision(std::numeric_limits<double>::digits10 + 2); I believe that std::numeric_limits<double>::digits10 returns the number of digits required to hold the maximum value in base 10. So either a) I misunderstand the function and/or application of std::numeric_limits b) its incorrectly implemented on your platform c) you think you have more precision than you actually do. look into this and check back Robert Ramey Adam M wrote:
Hi,
I am using Boost.Serialization to serialize a std::map<std::string, double>.
It works fine, except that the precision on the double is not enough for my application.
Is it possible to manipulate the precision used when serializing/deserializing double's within an STL container? I tried using setprecision(), but it doesn't understand the "&" stream operator that the Serialization library uses.
Thanks, Adam

Hi Robert, It turns out I was losing my precision before I even got into Boost.Serialization. Thanks for the tip. -Adam On Sat, 12 Nov 2005 12:42:48 -0800, "Robert Ramey" <ramey@rrsd.com> said:
The precision is set in basic_text_oprimitive.hpp line 139. with the statement: os << std::setprecision(std::numeric_limits<double>::digits10 + 2);
I believe that std::numeric_limits<double>::digits10 returns the number of digits required to hold the maximum value in base 10. So either
a) I misunderstand the function and/or application of std::numeric_limits b) its incorrectly implemented on your platform c) you think you have more precision than you actually do.
look into this and check back
Robert Ramey
Adam M wrote:
Hi,
I am using Boost.Serialization to serialize a std::map<std::string, double>.
It works fine, except that the precision on the double is not enough for my application.
Is it possible to manipulate the precision used when serializing/deserializing double's within an STL container? I tried using setprecision(), but it doesn't understand the "&" stream operator that the Serialization library uses.
Thanks, Adam
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Adam M
-
Robert Ramey