diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-06-28 01:00:23 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-06-28 01:00:23 +0200 |
commit | 7265fb0597a52692ffeb455a3da1271903b8cd58 (patch) | |
tree | 096426673daaac690735a86b10a26c2e625cd424 /src/corelib | |
parent | 0d6b4b519272915c2690ee12d1834823747233ab (diff) | |
parent | 2a756e294e2efa4bcb2b51afd1c20822df251f29 (diff) |
Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I912bd8851c390302414d3dfb3c8220df5a0d5630
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/serialization/qjsonwriter.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/corelib/serialization/qjsonwriter.cpp b/src/corelib/serialization/qjsonwriter.cpp index 5b246837d2..012d3bea86 100644 --- a/src/corelib/serialization/qjsonwriter.cpp +++ b/src/corelib/serialization/qjsonwriter.cpp @@ -43,6 +43,7 @@ #include "qjsonwriter_p.h" #include "qjson_p.h" #include "private/qutfcodec_p.h" +#include <private/qnumeric_p.h> QT_BEGIN_NAMESPACE @@ -135,8 +136,9 @@ static void valueToJson(const QJsonPrivate::Base *b, const QJsonPrivate::Value & case QJsonValue::Double: { const double d = v.toDouble(b); if (qIsFinite(d)) { // +2 to format to ensure the expected precision - const double abs = std::abs(d); - json += QByteArray::number(d, abs == static_cast<quint64>(abs) ? 'f' : 'g', QLocale::FloatingPointShortest); + quint64 absInt; + json += QByteArray::number(d, convertDoubleTo(std::abs(d), &absInt) ? 'f' : 'g', + QLocale::FloatingPointShortest); } else { json += "null"; // +INF || -INF || NaN (see RFC4627#section2.4) } |