Serialization: using maximum precision when converting double to string.

This commit is contained in:
Benjamin Bouvier 2012-07-10 14:46:12 +02:00
commit ad89e280f9
2 changed files with 3 additions and 0 deletions

View file

@ -3,6 +3,7 @@
# include <string>
# include <sstream>
# include <limits>
# include "Entity.h"
@ -60,6 +61,7 @@ template<class T>
inline void String::deserialize( T & value )
{
std::stringstream ss;
ss.precision(std::numeric_limits<double>::digits10 + 1);
ss << *this;
ss >> value;
}

View file

@ -76,6 +76,7 @@ namespace eoserial
String* make( const T & value )
{
std::stringstream ss;
ss.precision(std::numeric_limits<double>::digits10 + 1);
ss << value;
return new String( ss.str() );
}