-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Equality for floating point numbers of points #49
Comments
The appropriate epsilon for approximate equality varies by context, so I think if you need approximate equality you're best off creating your own function that compares the way you want. That said, I can see an argument for straight up disabling |
While I agree, I think a reasonable assumption for a general case could be made? template <typename T>
bool values_are_equal(T a, T b)
{
return a == b;
}
template <>
bool values_are_equal<double>(double a, double b)
{
return std::fabs(a - b) < (3.0 * std::numeric_limits<double>::epsilon());
} However, if we could not find a reasonable balance I would suggest disabling as well. |
The Catch unit test framework has an |
@joto - thanks. |
https://github.com/mapbox/geometry.hpp/blob/master/include/mapbox/geometry/point.hpp#L25
Would it be better in the case of double or float that we used an approximate equality here?
The text was updated successfully, but these errors were encountered: