From d8db6e9484884f9d93ef584e63e695ae0322fc8f Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 29 Jul 2022 16:12:24 +0200 Subject: V4: Fix exponentiation operator We need to use the same algorithm as for Math.pow(...). Since we have jsExponentiate() now, we can use it in all those places. The strange AIX special case is definitely not useful anymore. Task-number: QTBUG-105188 Change-Id: I43a251c71f1b547ad36855ac197080bfea8c94e3 Reviewed-by: Fabian Kosmale --- src/qml/jsruntime/qv4mathobject.cpp | 44 +------------------------------------ 1 file changed, 1 insertion(+), 43 deletions(-) (limited to 'src/qml/jsruntime/qv4mathobject.cpp') diff --git a/src/qml/jsruntime/qv4mathobject.cpp b/src/qml/jsruntime/qv4mathobject.cpp index 34a96a2141..418e29ffcb 100644 --- a/src/qml/jsruntime/qv4mathobject.cpp +++ b/src/qml/jsruntime/qv4mathobject.cpp @@ -342,49 +342,7 @@ ReturnedValue MathObject::method_pow(const FunctionObject *, const Value *, cons double x = argc > 0 ? argv[0].toNumber() : qt_qnan(); double y = argc > 1 ? argv[1].toNumber() : qt_qnan(); - if (std::isnan(y)) - RETURN_RESULT(Encode(qt_qnan())); - - if (y == 0) { - RETURN_RESULT(Encode(1)); - } else if (((x == 1) || (x == -1)) && std::isinf(y)) { - RETURN_RESULT(Encode(qt_qnan())); - } else if (((x == 0) && copySign(1.0, x) == 1.0) && (y < 0)) { - RETURN_RESULT(Encode(qInf())); - } else if ((x == 0) && copySign(1.0, x) == -1.0) { - if (y < 0) { - if (std::fmod(-y, 2.0) == 1.0) - RETURN_RESULT(Encode(-qt_inf())); - else - RETURN_RESULT(Encode(qt_inf())); - } else if (y > 0) { - if (std::fmod(y, 2.0) == 1.0) - RETURN_RESULT(Encode(copySign(0, -1.0))); - else - RETURN_RESULT(Encode(0)); - } - } - -#ifdef Q_OS_AIX - else if (qt_is_inf(x) && copySign(1.0, x) == -1.0) { - if (y > 0) { - if (std::fmod(y, 2.0) == 1.0) - RETURN_RESULT(Encode(-qt_inf())); - else - RETURN_RESULT(Encode(qt_inf())); - } else if (y < 0) { - if (std::fmod(-y, 2.0) == 1.0) - RETURN_RESULT(Encode(copySign(0, -1.0))); - else - RETURN_RESULT(Encode(0)); - } - } -#endif - else { - RETURN_RESULT(Encode(std::pow(x, y))); - } - // ### - RETURN_RESULT(Encode(qt_qnan())); + RETURN_RESULT(Encode(QQmlPrivate::jsExponentiate(x, y))); } ReturnedValue MathObject::method_random(const FunctionObject *, const Value *, const Value *, int) -- cgit v1.2.3