summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qglobal.h
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@nokia.com>2012-08-01 16:02:10 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-22 04:04:57 +0200
commit09dd19df5c4b708960e5aade568eb15d996ef200 (patch)
tree3a997704b1324dfb45f69d892128399affcac242 /src/corelib/global/qglobal.h
parent7f469ef4cc614925d7a4fdb3380ff5470e25b03b (diff)
Do not consider sign in qIsNull.
The current implementation of qIsNull only returns true if the value is positive zero. This behaviour is not useful for use cases like QPointF::isNull, where QPointF(-0, -0).isNull() will return false. There doesn't seem to be a reason why the function exhibits this behaviour (-0.0 is not accounted for in the unit tests), and for the case of QSizeF::scale it causes a bug: qIsNull is used to check for division by 0.0 before it proceeds, which fails in the case of -0.0. Task-number: QTBUG-7303 Change-Id: I767e5280bd26614e8e78ae62b274eb9bc4ade385 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Diffstat (limited to 'src/corelib/global/qglobal.h')
-rw-r--r--src/corelib/global/qglobal.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 546c6cf575..2acff12e3a 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -813,7 +813,7 @@ Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f)
/*
This function tests a double for a null value. It doesn't
check whether the actual value is 0 or close to 0, but whether
- it is binary 0.
+ it is binary 0, disregarding sign.
*/
static inline bool qIsNull(double d)
{
@@ -823,13 +823,13 @@ static inline bool qIsNull(double d)
};
U val;
val.d = d;
- return val.u == quint64(0);
+ return (val.u & Q_UINT64_C(0x7fffffffffffffff)) == 0;
}
/*
This function tests a float for a null value. It doesn't
check whether the actual value is 0 or close to 0, but whether
- it is binary 0.
+ it is binary 0, disregarding sign.
*/
static inline bool qIsNull(float f)
{
@@ -839,7 +839,7 @@ static inline bool qIsNull(float f)
};
U val;
val.f = f;
- return val.u == 0u;
+ return (val.u & 0x7fffffff) == 0;
}
/*