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>
This commit is contained in:
parent
a39ca22b4d
commit
2dcd3939a8
@ -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; }
|
||||
|
Loading…
Reference in New Issue
Block a user