From 0c5b2cf69ae20f83cbd894bb19d0e111623bae0f Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Sun, 10 May 2015 15:53:54 +0200 Subject: univalue: add support for real, fix percision and make it json_spirit compatible - avoid breaking the API because of different number/percision handling --- src/univalue/univalue.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/univalue/univalue.cpp') 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 #include +#include #include #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 -- cgit v1.2.3