From fde7f3d03782c801901f511131458d6fcb1021a5 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sun, 29 Mar 2009 21:47:53 +0200 Subject: 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. --- src/corelib/global/qglobal.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 -- cgit v0.12