summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2010-05-27 16:16:11 +0100
committerJosé Fonseca <[email protected]>2010-05-30 16:38:41 +0100
commitb57e18c35cf651addecdfb2339768fbb29c257f5 (patch)
tree74eae731e0b07383a402507d52749798e1c5e2ac
parentf503b3dd9d6522abdabab1e25d0652c9d3079421 (diff)
util: Add inline function for approximate floating point comparison.
-rw-r--r--src/gallium/auxiliary/util/u_math.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
index d1ec13def30..ee52c09e347 100644
--- a/src/gallium/auxiliary/util/u_math.h
+++ b/src/gallium/auxiliary/util/u_math.h
@@ -335,6 +335,15 @@ util_iround(float f)
}
+/**
+ * Approximate floating point comparison
+ */
+static INLINE boolean
+util_is_approx(float a, float b, float tol)
+{
+ return fabs(b - a) <= tol;
+}
+
/**
* Test if x is NaN or +/- infinity.