diff --git a/glm/gtc/ulp.inl b/glm/gtc/ulp.inl index fb6a96cb..d4e718d6 100644 --- a/glm/gtc/ulp.inl +++ b/glm/gtc/ulp.inl @@ -9,6 +9,7 @@ /// is preserved. #include "../detail/type_int.hpp" +#include "epsilon.hpp" #include #include #include @@ -304,7 +305,7 @@ namespace glm if(x < y) { T temp = x; - while(temp != y)// && ulp < std::numeric_limits::max()) + while(glm::epsilonNotEqual(temp, y, glm::epsilon()))// && ulp < std::numeric_limits::max()) { ++ulp; temp = next_float(temp); @@ -313,7 +314,7 @@ namespace glm else if(y < x) { T temp = y; - while(temp != x)// && ulp < std::numeric_limits::max()) + while(glm::epsilonNotEqual(temp, x, glm::epsilon()))// && ulp < std::numeric_limits::max()) { ++ulp; temp = next_float(temp); diff --git a/test/gtc/gtc_ulp.cpp b/test/gtc/gtc_ulp.cpp index 9b416d6c..58ef5ce1 100644 --- a/test/gtc/gtc_ulp.cpp +++ b/test/gtc/gtc_ulp.cpp @@ -1,4 +1,5 @@ #include +#include #include int test_ulp_float_dist() @@ -8,7 +9,7 @@ int test_ulp_float_dist() float A = 1.0f; float B = glm::next_float(A); - Error += glm::epsilonNotEqual(A, B, glm::epsilon()) ? 0 : 1; + Error += !glm::epsilonEqual(A, B, glm::epsilon()) ? 0 : 1; float C = glm::prev_float(B); Error += glm::epsilonEqual(A, C, glm::epsilon()) ? 0 : 1; @@ -29,9 +30,9 @@ int test_ulp_float_step() for(int i = 10; i < 1000; i *= 10) { float B = glm::next_float(A, i); - Error += A != B ? 0 : 1; + Error += !glm::epsilonEqual(A, B, glm::epsilon()) ? 0 : 1; float C = glm::prev_float(B, i); - Error += A == C ? 0 : 1; + Error += glm::epsilonEqual(A, C, glm::epsilon()) ? 0 : 1; int D = glm::float_distance(A, B); Error += D == i ? 0 : 1; @@ -49,9 +50,9 @@ int test_ulp_double_dist() double A = 1.0; double B = glm::next_float(A); - Error += A != B ? 0 : 1; + Error += !glm::epsilonEqual(A, B, glm::epsilon()) ? 0 : 1; double C = glm::prev_float(B); - Error += A == C ? 0 : 1; + Error += glm::epsilonEqual(A, C, glm::epsilon()) ? 0 : 1; int D = glm::float_distance(A, B); Error += D == 1 ? 0 : 1; @@ -70,9 +71,9 @@ int test_ulp_double_step() for(int i = 10; i < 1000; i *= 10) { double B = glm::next_float(A, i); - Error += A != B ? 0 : 1; + Error += !glm::epsilonEqual(A, B, glm::epsilon()) ? 0 : 1; double C = glm::prev_float(B, i); - Error += A == C ? 0 : 1; + Error += glm::epsilonEqual(A, C, glm::epsilon()) ? 0 : 1; int D = glm::float_distance(A, B); Error += D == i ? 0 : 1;