Serialization: using maximum precision when converting double to string.
This commit is contained in:
parent
79c7a263a3
commit
ad89e280f9
2 changed files with 3 additions and 0 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
# include <string>
|
# include <string>
|
||||||
# include <sstream>
|
# include <sstream>
|
||||||
|
# include <limits>
|
||||||
|
|
||||||
# include "Entity.h"
|
# include "Entity.h"
|
||||||
|
|
||||||
|
|
@ -60,6 +61,7 @@ template<class T>
|
||||||
inline void String::deserialize( T & value )
|
inline void String::deserialize( T & value )
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
ss.precision(std::numeric_limits<double>::digits10 + 1);
|
||||||
ss << *this;
|
ss << *this;
|
||||||
ss >> value;
|
ss >> value;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@ namespace eoserial
|
||||||
String* make( const T & value )
|
String* make( const T & value )
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
ss.precision(std::numeric_limits<double>::digits10 + 1);
|
||||||
ss << value;
|
ss << value;
|
||||||
return new String( ss.str() );
|
return new String( ss.str() );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in a new issue