aboutsummaryrefslogtreecommitdiffstats
path: root/qmljs_runtime.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-01-03 16:16:03 +0100
committerLars Knoll <lars.knoll@digia.com>2013-01-03 16:44:03 +0100
commitcf2c03a5a42e11e9f05ee02f0065ab008dec321e (patch)
treebbb22ca0ad1cd0fd6e8a46b98fc2103214d15d1b /qmljs_runtime.cpp
parent9951c682ff93a940db75f6a46b843a7a05660e29 (diff)
Fix remaining number-to-string failures in chapter 9
...by using the double-conversion code from http://code.google.com/p/double-conversion/ Change-Id: I4cfc17b65c811b7c20a856d1d38961bec78d85a2 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'qmljs_runtime.cpp')
-rw-r--r--qmljs_runtime.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/qmljs_runtime.cpp b/qmljs_runtime.cpp
index 3d6e0536ca..293e1dbe34 100644
--- a/qmljs_runtime.cpp
+++ b/qmljs_runtime.cpp
@@ -54,6 +54,8 @@
#include <typeinfo>
#include <stdlib.h>
+#include "3rdparty/double-conversion/double-conversion.h"
+
namespace QQmlJS {
namespace VM {
@@ -65,8 +67,12 @@ QString numberToString(double num, int radix = 10)
return QLatin1String(num < 0 ? "-Infinity" : "Infinity");
}
- if (radix == 10)
- return QString::number(num, 'g', 16);
+ if (radix == 10) {
+ char str[100];
+ double_conversion::StringBuilder builder(str, sizeof(str));
+ double_conversion::DoubleToStringConverter::EcmaScriptConverter().ToShortest(num, &builder);
+ return QString::fromLatin1(builder.Finalize());
+ }
QString str;
bool negative = false;