Mesa (master): util: Add inline function for approximate floating point comparison.
Jose Fonseca
jrfonseca at kemper.freedesktop.org
Sun May 30 15:40:16 UTC 2010
Module: Mesa
Branch: master
Commit: b57e18c35cf651addecdfb2339768fbb29c257f5
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b57e18c35cf651addecdfb2339768fbb29c257f5
Author: José Fonseca <jfonseca at vmware.com>
Date: Thu May 27 16:16:11 2010 +0100
util: Add inline function for approximate floating point comparison.
---
src/gallium/auxiliary/util/u_math.h | 9 +++++++++
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 d1ec13d..ee52c09 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.
More information about the mesa-commit
mailing list