diff options
author | Jonas Schnelli <jonas.schnelli@include7.ch> | 2015-05-10 15:53:54 +0200 |
---|---|---|
committer | Jonas Schnelli <jonas.schnelli@include7.ch> | 2015-06-04 09:16:06 +0200 |
commit | 0c5b2cf69ae20f83cbd894bb19d0e111623bae0f (patch) | |
tree | 5adf63f805d4908ce5224c83bea99a763dfdf21d /src/univalue/univalue.cpp | |
parent | 21c10de8c2de17a6357dbbcea7613b41f6ab8449 (diff) |
univalue: add support for real, fix percision and make it json_spirit compatible
- avoid breaking the API because of different number/percision handling
Diffstat (limited to 'src/univalue/univalue.cpp')
-rw-r--r-- | src/univalue/univalue.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/univalue/univalue.cpp b/src/univalue/univalue.cpp index 6870ce59eb..994d93113a 100644 --- a/src/univalue/univalue.cpp +++ b/src/univalue/univalue.cpp @@ -4,6 +4,7 @@ #include <stdint.h> #include <ctype.h> +#include <iomanip> #include <sstream> #include "univalue.h" @@ -78,9 +79,11 @@ bool UniValue::setFloat(double val) string s; ostringstream oss; - oss << val; + oss << std::setprecision(16) << val; - return setNumStr(oss.str()); + bool ret = setNumStr(oss.str()); + typ = VREAL; + return ret; } bool UniValue::setStr(const string& val_) @@ -203,6 +206,7 @@ const char *uvTypeName(UniValue::VType t) case UniValue::VARR: return "array"; case UniValue::VSTR: return "string"; case UniValue::VNUM: return "number"; + case UniValue::VREAL: return "number"; } // not reached |