Skip to content

Replace ZERO_TOLERANCE #19

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

Closed
asmaloney opened this issue Apr 24, 2020 · 3 comments
Closed

Replace ZERO_TOLERANCE #19

asmaloney opened this issue Apr 24, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@asmaloney
Copy link
Member

Describe the feature you would like

We had discussed replacing ZERO_TOLERANCE with the old FLT_EPSILON.

Maybe what we should provide here is inline methods instead. ZERO_TOLERANCE is mostly used for comparison - "is this less than zero-ish?" or "is this greater than zero-ish?"

This would make it a bit more readable and eliminate casting issues and warnings.

if (range < CCLib::ZERO_TOLERANCE)

becomes:

if ( CCLib::lessThanEpsilon( range ) )

This might be implemented like this:

inline bool	lessThanEpsilon( double x )
{
   return x < std::numeric_limits<double>::epsilon();
}

inline bool	lessThanEpsilon( float x )
{
   return x < std::numeric_limits<float>::epsilon();
}
@asmaloney asmaloney added the enhancement New feature or request label Apr 24, 2020
@dgirardeau
Copy link
Member

Ok, then simply a template version?

template inline bool lessThanEpsilon( T x )
{
return x < std::numeric_limits::epsilon();
}

@asmaloney
Copy link
Member Author

I considered that, but wanted to avoid templates as much as possible. I think it's overkill for this. Just causes longer compile times for no real return.

@asmaloney
Copy link
Member Author

This was rolled into the plan for #20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants