aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2017-03-08 11:20:33 +0100
committerErik Verbruggen <erik.verbruggen@qt.io>2017-03-08 12:53:42 +0000
commit4aabede9348d195cec2ca6c4718576aa35464e3e (patch)
treed0721f9ee9da2e00f0a84859b19370f494fbe2c1
parentfb0490dd653e4856a3595bd7e49c3127215170d1 (diff)
JS: Fix 0 == -0
The double representation of 0 and -0 are different in the sign bit, so the raw values are not the same. However, neither is managed, so non-strict equality comparison erroneously returned false. Task-number: QTBUG-56808 Change-Id: If966ddbc9f1a1c006dc5901aecafca063f71e404 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 57ad181030..b31e07b979 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -1758,6 +1758,8 @@ Bool Runtime::method_compareEqual(const Value &left, const Value &right)
return !left.isNaN();
if (left.type() == right.type()) {
+ if (left.isDouble() && left.doubleValue() == 0 && right.doubleValue() == 0)
+ return true; // this takes care of -0 == +0 (which obviously have different raw values)
if (!left.isManaged())
return false;
if (left.isString() == right.isString())