summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago@kde.org>2011-07-12 17:08:35 +0200
committerQt by Nokia <qt-info@nokia.com>2011-07-20 10:29:33 +0200
commit2dcd3939a8bd5ff743e4c87f87b2d81b1a101467 (patch)
tree8844fb5f80d53d41d0168fb1a07df9e716758a1c
parenta39ca22b4d30c9ea568c5d24f1b5bbf388f033ed (diff)
Cleanup qRound and qRound64: provide overloads for double and float
Instead of having #ifdefs for the type of qreal, simply provide overloads for both types. Change-Id: I58582f57d5cd68fcad3fe9efb5fea5935f61b9e3 Merge-request: 17 Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com> Reviewed-on: http://codereview.qt.nokia.com/1542 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
-rw-r--r--src/corelib/global/qglobal.h15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index e91e8afdbc..63333b6233 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1173,16 +1173,15 @@ typedef double qreal;
template <typename T>
Q_DECL_CONSTEXPR inline T qAbs(const T &t) { return t >= 0 ? t : -t; }
-Q_DECL_CONSTEXPR inline int qRound(qreal d)
-{ return d >= qreal(0.0) ? int(d + qreal(0.5)) : int(d - int(d-1) + qreal(0.5)) + int(d-1); }
+Q_DECL_CONSTEXPR inline int qRound(double d)
+{ return d >= 0.0 ? int(d + 0.5) : int(d - int(d-1) + 0.5) + int(d-1); }
+Q_DECL_CONSTEXPR inline int qRound(float d)
+{ return d >= 0.0f ? int(d + 0.5f) : int(d - int(d-1) + 0.5f) + int(d-1); }
-#if defined(QT_NO_FPU) || defined(QT_ARCH_ARM) || defined(QT_ARCH_WINDOWSCE) || defined(QT_ARCH_SYMBIAN)
Q_DECL_CONSTEXPR inline qint64 qRound64(double d)
-{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - qreal(qint64(d-1)) + 0.5) + qint64(d-1); }
-#else
-Q_DECL_CONSTEXPR inline qint64 qRound64(qreal d)
-{ return d >= qreal(0.0) ? qint64(d + qreal(0.5)) : qint64(d - qreal(qint64(d-1)) + qreal(0.5)) + qint64(d-1); }
-#endif
+{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - double(qint64(d-1)) + 0.5) + qint64(d-1); }
+Q_DECL_CONSTEXPR inline qint64 qRound64(float d)
+{ return d >= 0.0f ? qint64(d + 0.5f) : qint64(d - float(qint64(d-1)) + 0.5f) + qint64(d-1); }
template <typename T>
Q_DECL_CONSTEXPR inline const T &qMin(const T &a, const T &b) { return (a < b) ? a : b; }