diff --git a/glm/ext/scalar_relational.inl b/glm/ext/scalar_relational.inl index 27370e14..c85583ef 100644 --- a/glm/ext/scalar_relational.inl +++ b/glm/ext/scalar_relational.inl @@ -25,10 +25,7 @@ namespace glm // Different signs means they do not match. if(a.negative() != b.negative()) - { - // Check for equality to make sure +0==-0 - return a.mantissa() == b.mantissa() && a.exponent() == b.exponent(); - } + return false; // Find the difference in ULPs. typename detail::float_t::int_type const DiffULPs = abs(a.i - b.i); diff --git a/readme.md b/readme.md index 73e16c91..1b270486 100644 --- a/readme.md +++ b/readme.md @@ -76,6 +76,7 @@ glm::mat4 camera(float Translate, glm::vec2 const& Rotate) - Fixed GLM_HAS_CXX11_STL broken on Clang with Linux #926 - Fixed Clang or GCC build due to wrong GLM_HAS_IF_CONSTEXPR definition #907 - Fixed CUDA 9 build #910 +- Fixed equal ULP variation when using negative sign #965 #### Deprecation: - Removed CMake install and uninstall scripts diff --git a/test/ext/ext_scalar_relational.cpp b/test/ext/ext_scalar_relational.cpp index 7cd7a6cf..61f1999a 100644 --- a/test/ext/ext_scalar_relational.cpp +++ b/test/ext/ext_scalar_relational.cpp @@ -71,6 +71,25 @@ static int test_notEqual_ulps() return Error; } +static int test_equal_sign() +{ + int Error = 0; + + Error += !glm::equal(-0.0f, 0.0f, 2) ? 0 : 1; + Error += !glm::equal(-0.0, 0.0, 2) ? 0 : 1; + + Error += !glm::equal(-1.0f, 2.0f, 2) ? 0 : 1; + Error += !glm::equal(-1.0, 2.0, 2) ? 0 : 1; + + Error += !glm::equal(-0.00001f, 1.00000f, 2) ? 0 : 1; + Error += !glm::equal(-0.00001, 1.00000, 2) ? 0 : 1; + + Error += !glm::equal(-1.0f, 1.0f, 2) ? 0 : 1; + Error += !glm::equal(-1.0, 1.0, 2) ? 0 : 1; + + return Error; +} + int main() { int Error = 0; @@ -81,5 +100,7 @@ int main() Error += test_equal_ulps(); Error += test_notEqual_ulps(); + Error += test_equal_sign(); + return Error; }