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 d1ec13def30f831e81a11f95d65b917ef4177cb2..ee52c09e3476cbdab965445242dbcf72a8082874 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.