aboutsummaryrefslogtreecommitdiffstats
path: root/qmljs_runtime.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2012-12-12 20:34:31 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2012-12-12 11:49:14 +0100
commit5cf108e7a530229f4c9fa2751ec0aac42924fea6 (patch)
tree3f017801f431315831dd21d9d0ee3ce87bb13a5b /qmljs_runtime.h
parent47b01bb7e5ac8812470d5840534aeaa2eb342164 (diff)
Correctly handle negative 0
-0 and +0 are two distinct numbers. Since integers only have one 0 value, we need to convert the number to double when negating a 0 Change-Id: I915c4bd7168eece947fa91c6b65137a873d4f75a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'qmljs_runtime.h')
-rw-r--r--qmljs_runtime.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/qmljs_runtime.h b/qmljs_runtime.h
index 1021d4e89d..2de6f19f55 100644
--- a/qmljs_runtime.h
+++ b/qmljs_runtime.h
@@ -457,7 +457,8 @@ inline Value __qmljs_uminus(Value value, ExecutionContext *ctx)
{
TRACE1(value);
- if (value.isInteger())
+ // +0 != -0, so we need to convert to double when negating 0
+ if (value.isInteger() && value.integerValue())
return Value::fromInt32(-value.integerValue());
double n = __qmljs_to_number(value, ctx);
return Value::fromDouble(-n);