diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-07-29 16:12:24 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-08-03 08:19:54 +0200 |
commit | d8db6e9484884f9d93ef584e63e695ae0322fc8f (patch) | |
tree | ba6a525b1cdd0aca8dcbb449d7a3e87042dd5554 /src/qml/jsruntime/qv4mathobject.cpp | |
parent | b44c06dbc726d81481a0c6e28060ed3b3c9d4ecf (diff) |
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 <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4mathobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4mathobject.cpp | 44 |
1 files changed, 1 insertions, 43 deletions
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) |