diff options
-rw-r--r-- | src/qml/jsruntime/qv4mathobject.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4mathobject.cpp b/src/qml/jsruntime/qv4mathobject.cpp index c6b74e7aba..382185657e 100644 --- a/src/qml/jsruntime/qv4mathobject.cpp +++ b/src/qml/jsruntime/qv4mathobject.cpp @@ -474,11 +474,14 @@ ReturnedValue MathObject::method_random(const FunctionObject *, const Value *, c ReturnedValue MathObject::method_round(const FunctionObject *, const Value *, const Value *argv, int argc) { double v = argc ? argv[0].toNumber() : qt_qnan(); - if (std::isnan(v) || qt_is_inf(v) || qIsNull(v)) + if (!std::isfinite(v)) RETURN_RESULT(Encode(v)); - v = copySign(std::floor(v + 0.5), v); - RETURN_RESULT(Encode(v)); + if (v < 0.5 && v >= -0.5) + v = std::copysign(0.0, v); + else + v = std::floor(v + 0.5); + RETURN_RESULT(Encode(v)); } ReturnedValue MathObject::method_sign(const FunctionObject *, const Value *, const Value *argv, int argc) |