diff --git a/doomsday/libdeng2/include/de/math.h b/doomsday/libdeng2/include/de/math.h index 8a8b62d0a1..9890652699 100644 --- a/doomsday/libdeng2/include/de/math.h +++ b/doomsday/libdeng2/include/de/math.h @@ -36,6 +36,7 @@ namespace de { #undef PI ddouble const PI = 3.14159265358979323846; ddouble const EPSILON = 1.0e-7; +dfloat const FLOAT_EPSILON = 1.0e-5; /// Absolute value. template @@ -86,8 +87,15 @@ inline dint64 floor(ddouble const &value) { return dint64(std::floor(value)); } -/// Compare two floating-point values for equality, with the precision of EPSILON. -inline ddouble fequal(ddouble a, ddouble b) { +/// Compare two single-precision floating-point values for equality, +/// with the precision of FLOAT_EPSILON. +inline bool fequal(dfloat a, dfloat b) { + return abs(a - b) < FLOAT_EPSILON; +} + +/// Compare two double-precision floating-point values for equality, +/// with the precision of EPSILON. +inline bool fequal(ddouble a, ddouble b) { return abs(a - b) < EPSILON; }