Skip to content

Mark ZERO_TOLERANCE as deprecated - #40

Merged
asmaloney merged 3 commits into
masterfrom
epsilon
May 4, 2020
Merged

asmaloney merged 3 commits into
masterfrom
epsilon

Conversation

@asmaloney

Copy link
Copy Markdown
Member

Part of #20

@asmaloney
asmaloney requested a review from dgirardeau May 3, 2020 12:12

@dgirardeau dgirardeau left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay so we should really have only one 'epsilon' and this would really be CCCoreLib epsilon with a 'not that small value'. Because it's not a question of type, but a question of typical units / scales.

Comment thread include/ManualSegmentationTools.h Resolved
Comment thread src/WeibullDistribution.cpp Resolved
@asmaloney

Copy link
Copy Markdown
Member Author

Oh, alright! So I think when we discussed this before we talked about adding a float version of the var.

So according to your comment, that would look like this:

constexpr double ZERO_TOLERANCE_D = static_cast<double>(std::numeric_limits<float>::epsilon());
constexpr float ZERO_TOLERANCE_F = std::numeric_limits<float>::epsilon();

Then we can at least avoid extra casting and it's more explicit.

Would we then use ZERO_TOLERANCE_D in the double versions of LessThanEpsilon, etc.? Or are there cases where we actually want the real double epsilon?

@asmaloney

Copy link
Copy Markdown
Member Author

Or are there cases where we actually want the real double epsilon?

Actually, given that we changing where ZERO_TOLERANCE is used - there shouldn't be!

@dgirardeau

Copy link
Copy Markdown
Member

Yes I was going to say that there should only be one 'value' for ZERO_TOLERANCE (in two flavors). And if we need another epsilon value, then we would use something else than ZERO_TOLERANCE.

@dgirardeau

Copy link
Copy Markdown
Member

(or is flavours? :D )

@asmaloney

asmaloney commented May 4, 2020 •

Copy link
Copy Markdown
Member Author

Is this a reasonable explanation for the comments?

ZERO_TOLERANCE_F and ZERO_TOLERANCE_D are used when we compare, or want to set a variable to, "close to zero". It is defined as std::numeric_limits<float>::epsilon() for both single and double precision numbers because using std::numeric_limits<double>::epsilon() results in numbers that are too small for our purposes.

@dgirardeau

Copy link
Copy Markdown
Member

I guess it's std::numeric_limits'<'float'>'::epsilon() but markdown is removing the '<'float'>' or '<'double'>' ? :D.

Then yes.

@asmaloney

Copy link
Copy Markdown
Member Author

Ah yes :-)

Comment thread include/CCConst.h Resolved
@asmaloney
asmaloney merged commit 6acd199 into master May 4, 2020
@asmaloney
asmaloney deleted the epsilon branch May 4, 2020 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants