summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qmath.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel/qmath.h')
-rw-r--r--src/corelib/kernel/qmath.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/corelib/kernel/qmath.h b/src/corelib/kernel/qmath.h
index fd39f46c1b..72057ee16d 100644
--- a/src/corelib/kernel/qmath.h
+++ b/src/corelib/kernel/qmath.h
@@ -113,7 +113,7 @@ class QHypotHelper
public:
QHypotHelper(T first) : scale(qAbs(first)), total(1) {}
T result() const
- { return qIsFinite(scale) ? scale > 0 ? scale * T(std::sqrt(total)) : T(0) : scale; }
+ { return qIsFinite(scale) ? scale > 0 ? scale * T(qSqrt(total)) : T(0) : scale; }
template<typename F, typename ...Fs>
auto add(F first, Fs... rest) const
@@ -133,7 +133,7 @@ public:
return QHypotHelper<R>(scale, total);
if (val > scale) {
const R ratio = scale / next;
- return QHypotHelper<R>(val, total * ratio * ratio + 1);
+ return QHypotHelper<R>(val, total * ratio * ratio + R(1));
}
const R ratio = next / scale;
return QHypotHelper<R>(scale, total + ratio * ratio);
@@ -370,6 +370,16 @@ constexpr inline quint64 qNextPowerOfTwo(qint64 v)
return qNextPowerOfTwo(quint64(v));
}
+constexpr inline unsigned long qNextPowerOfTwo(unsigned long v)
+{
+ return qNextPowerOfTwo(QIntegerForSizeof<long>::Unsigned(v));
+}
+
+constexpr inline unsigned long qNextPowerOfTwo(long v)
+{
+ return qNextPowerOfTwo(QIntegerForSizeof<long>::Unsigned(v));
+}
+
QT_END_NAMESPACE
#endif // QMATH_H