Skip to content
Snippets Groups Projects
Commit b5b9f7f8 authored by Hadrien G's avatar Hadrien G Committed by Hadrien Benjamin Grasland
Browse files

Added NaN-proof comparison function for doubles

parent f03ad8dd
No related branches found
No related tags found
No related merge requests found
...@@ -108,9 +108,9 @@ compare(const T& x, const T& y) ...@@ -108,9 +108,9 @@ compare(const T& x, const T& y)
} }
// ...but we'll want to tweak that a little for floats, to handle NaNs better... // ...but we'll want to tweak that a little for floats, to handle NaNs better...
template <> template <typename T>
Ordering Ordering
compare(const float& x, const float& y) compareFloat(const T& x, const T& y)
{ {
if (std::isless(x, y)) { if (std::isless(x, y)) {
return Ordering::SMALLER; return Ordering::SMALLER;
...@@ -121,6 +121,19 @@ compare(const float& x, const float& y) ...@@ -121,6 +121,19 @@ compare(const float& x, const float& y)
} }
} }
template<>
Ordering
compare(const float& x, const float& y)
{
return compareFloat(x, y);
}
template<>
Ordering
compare(const double& x, const double& y) {
return compareFloat(x, y);
}
// ...and for vectors, where the default lexicographic comparison cannot // ...and for vectors, where the default lexicographic comparison cannot
// efficiently tell all of what we want in a single vector iteration pass. // efficiently tell all of what we want in a single vector iteration pass.
template <typename U> template <typename U>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment