Skip to content

Commit

Permalink
Merge pull request g-truc#672 from amc522/master
Browse files Browse the repository at this point in the history
Fixing checks for nan in fmin/fmax g-truc#672
  • Loading branch information
Groovounet authored Aug 21, 2017
2 parents d550798 + 8150e48 commit 4e0c876
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 4 additions & 4 deletions glm/gtx/extended_min_max.inl
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ namespace glm
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'fmin' only accept floating-point input");

if (isnan(y))
return x;
if (isnan(x))
return y;
if (isnan(y))
return x;

Expand Down Expand Up @@ -176,8 +176,8 @@ namespace glm
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'fmax' only accept floating-point input");

if (isnan(y))
return x;
if (isnan(x))
return y;
if (isnan(y))
return x;

Expand Down
7 changes: 7 additions & 0 deletions test/gtx/gtx_extended_min_max.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#define GLM_ENABLE_EXPERIMENTAL

#include <glm/gtx/extended_min_max.hpp>
#include <glm/gtc/vec1.hpp>
#include <glm/gtc/epsilon.hpp>
Expand All @@ -18,6 +19,9 @@ namespace fmin_
glm::vec1 A0 = glm::fmin(glm::vec1(1), glm::vec1(Zero_f / 0.0f));
Error += glm::epsilonEqual(A0.x, 1.0f, glm::epsilon<float>()) ? 0 : 1;

glm::vec1 A1 = glm::fmin(glm::vec1(Zero_f / 0.0f), glm::vec1(1));
Error += glm::epsilonEqual(A1.x, 1.0f, glm::epsilon<float>()) ? 0 : 1;

glm::vec2 B0 = glm::fmin(glm::vec2(1), glm::vec2(1));
glm::vec2 B1 = glm::fmin(glm::vec2(1), 1.0f);
bool B2 = glm::all(glm::equal(B0, B1));
Expand Down Expand Up @@ -47,6 +51,9 @@ namespace fmax_
glm::vec1 A0 = glm::fmax(glm::vec1(1), glm::vec1(Zero_f / 0.0f));
Error += glm::epsilonEqual(A0.x, 1.0f, glm::epsilon<float>()) ? 0 : 1;

glm::vec1 A1 = glm::fmax(glm::vec1(Zero_f / 0.0f), glm::vec1(1));
Error += glm::epsilonEqual(A0.x, 1.0f, glm::epsilon<float>()) ? 0 : 1;

glm::vec2 B0 = glm::fmax(glm::vec2(1), glm::vec2(1));
glm::vec2 B1 = glm::fmax(glm::vec2(1), 1.0f);
bool B2 = glm::all(glm::equal(B0, B1));
Expand Down

0 comments on commit 4e0c876

Please sign in to comment.