util: Add inline function for approximate floating point comparison.
authorJosé Fonseca <jfonseca@vmware.com>
Thu, 27 May 2010 15:16:11 +0000 (16:16 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Sun, 30 May 2010 15:38:41 +0000 (16:38 +0100)
src/gallium/auxiliary/util/u_math.h

index d1ec13d..ee52c09 100644 (file)
@@ -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.