summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qglobal.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2009-03-29 19:47:53 (GMT)
committerBjoern Erik Nilsen <bjorn.nilsen@nokia.com>2009-04-07 13:51:08 (GMT)
commitfde7f3d03782c801901f511131458d6fcb1021a5 (patch)
treea42fa854efaa38ba7dddafbd909696f4f7e15210 /src/corelib/global/qglobal.h
parentbaf61b32cf4aa554ee3dbb4a22b99e854d5ebd34 (diff)
downloadQt-fde7f3d03782c801901f511131458d6fcb1021a5.zip
Qt-fde7f3d03782c801901f511131458d6fcb1021a5.tar.gz
Qt-fde7f3d03782c801901f511131458d6fcb1021a5.tar.bz2
Add an internal qIsFuzzyNull(double) method
The method can help to avoid many calls to the rather expensive qFuzzyCompare in the cases where we compare a number against 0 or 1.
Diffstat (limited to 'src/corelib/global/qglobal.h')
-rw-r--r--src/corelib/global/qglobal.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 672862a..28b9d08 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1706,6 +1706,22 @@ static inline bool qFuzzyCompare(float p1, float p2)
return (qAbs(p1 - p2) <= 0.00001f * qMin(qAbs(p1), qAbs(p2)));
}
+/*!
+ \internal
+*/
+static inline bool qIsFuzzyNull(double d)
+{
+ return qAbs(d) <= 0.000000000001;
+}
+
+/*!
+ \internal
+*/
+static inline bool qIsFuzzyNull(float f)
+{
+ return qAbs(f) <= 0.00001f;
+}
+
/*
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