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

Add FloatCloseTo matcher and refactor *CloseTo matchers #385

Open
wants to merge 1 commit into
base: v2.3-candidates
Choose a base branch
from

Conversation

laz2
Copy link

@laz2 laz2 commented Apr 20, 2022

Updated pull request #226.

Changes:

  • Create base class BaseCloseTo for all closeTo matchers
  • Add FloatCloseTo matcher
  • Rename IsCloseTo matcher to DoubleCloseTo
  • Change error message for excluding errors in additional floating calculations (May user catch this error even with doubles?)

PS.
Example of error with additional floating calculations:

public static void main(String[] args) {
    var f = Math.abs(1.0f - 0.1f);
    System.out.println(f + " " + (f - 0.5f));
    var d = Math.abs(1.0d - 0.1d);
    System.out.println(d + " " + (d - 0.5d));
}

After run:

0.9 0.39999998
0.9 0.4

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.

None yet

1 participant