Skip to content

Commit

Permalink
Fixed|libdeng2: Incorrect return type for fequal
Browse files Browse the repository at this point in the history
Also added a single-precision version of the function.
  • Loading branch information
skyjake committed Apr 8, 2013
1 parent 49adde4 commit c64fa1d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions doomsday/libdeng2/include/de/math.h
Expand Up @@ -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 <typename Type>
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit c64fa1d

Please sign in to comment.