From b57e18c35cf651addecdfb2339768fbb29c257f5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Thu, 27 May 2010 16:16:11 +0100 Subject: [PATCH] util: Add inline function for approximate floating point comparison. --- src/gallium/auxiliary/util/u_math.h | 9 +++++++++ 1 file changed, 9 insertions(+) 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. -- 2.30.2