Commit 7331498e authored by Dominik Charousset's avatar Dominik Charousset

fixed precision issue in double serialization

parent aa877453
...@@ -28,9 +28,11 @@ ...@@ -28,9 +28,11 @@
\******************************************************************************/ \******************************************************************************/
#include <limits>
#include <string> #include <string>
#include <cstring>
#include <cstdint> #include <cstdint>
#include <sstream>
#include <cstring>
#include <type_traits> #include <type_traits>
#include "cppa/primitive_variant.hpp" #include "cppa/primitive_variant.hpp"
...@@ -74,8 +76,10 @@ class binary_writer { ...@@ -74,8 +76,10 @@ class binary_writer {
void operator()(const T& value, void operator()(const T& value,
typename enable_if<std::is_floating_point<T>::value>::type* = 0) { typename enable_if<std::is_floating_point<T>::value>::type* = 0) {
// write floating points as strings // write floating points as strings
std::string str = std::to_string(value); std::ostringstream iss;
(*this)(str); iss.precision(std::numeric_limits<T>::max_digits10);
iss << value;
(*this)(iss.str());
} }
void operator()(const std::string& str) { void operator()(const std::string& str) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment