Skip to content
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

Support for Epsilon on double and float #32

Open
GooRiOn opened this issue Oct 8, 2017 · 4 comments
Open

Support for Epsilon on double and float #32

GooRiOn opened this issue Oct 8, 2017 · 4 comments

Comments

@GooRiOn
Copy link
Member

GooRiOn commented Oct 8, 2017

Currently we don't support Epsilon in extensions for double and float. The suggestion is that each method should have default parameter like:

(this IValitRule<TObject, double> rule, double value, double epsilon = 0.0d)

so user can specify it, but it's not required. Each method should then consider this number in the calculations. Need to applied for:

  • IsGreaterThan()
  • IsLessThan()
  • IsEqualTo()
  • IsPositive()
  • IsNegative()
  • IsNonZero()
@GooRiOn GooRiOn added this to the 0.1.0 milestone Oct 8, 2017
@GooRiOn GooRiOn self-assigned this Oct 12, 2017
@GooRiOn GooRiOn removed this from the 0.1.0 milestone Oct 18, 2017
@GooRiOn GooRiOn removed their assignment Nov 29, 2017
@GKotfis
Copy link

GKotfis commented Oct 12, 2018

Help still needed? I can pick up this one :)

@GooRiOn
Copy link
Member Author

GooRiOn commented Oct 13, 2018

@GKotfis sure! Feel free to take this one :)

@GKotfis
Copy link

GKotfis commented Oct 15, 2018

Before I change bunch of code I'd like to show my approach.
I used algorithm from https://floating-point-gui.de/errors/comparison/
Here are the changes for IsGreaterThan for Double
GKotfis@aad3d76
I haven't write new unit test so far - just checked that this change doesn't broke anything.
What do you think about that?

@GooRiOn
Copy link
Member Author

GooRiOn commented Oct 23, 2018

I read the article and it looks good to me. Your implementation also looks good, however I think you should also consider handling Double.NaN values inside IsNearlyEqual method.

@GKotfis GKotfis mentioned this issue Jan 4, 2019
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants