From: José Fonseca Date: Thu, 27 May 2010 15:16:11 +0000 (+0100) Subject: util: Add inline function for approximate floating point comparison. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b57e18c35cf651addecdfb2339768fbb29c257f5;p=mesa.git util: Add inline function for approximate floating point comparison. --- 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.