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)
}
// ...but we'll want to tweak that a little for floats, to handle NaNs better...
template <>
template <typename T>
Ordering
compare(const float& x, const float& y)
compareFloat(const T& x, const T& y)
{
if (std::isless(x, y)) {
return Ordering::SMALLER;
......@@ -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
// efficiently tell all of what we want in a single vector iteration pass.
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