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

Issues with double comparisons #135

Closed
KabooHahahein opened this issue Apr 17, 2017 · 1 comment
Closed

Issues with double comparisons #135

KabooHahahein opened this issue Apr 17, 2017 · 1 comment
Labels

Comments

@KabooHahahein
Copy link

KabooHahahein commented Apr 17, 2017

  1. Comparisons of negative values to 0.0 will always succeed
    Eg. assert_that_double(-500, is_equal_to_double(0));
    Occurs because the largest absolute value is computed from the absolute of the max of the values. It should be the max of the absolute values.

  2. Relative epsilon calculations with 0 and a very small number will fail
    Eg. assert_that_double(0.000000000000001, is_equal_to_double(0));
    Occurs because the implementation uses relative epsilons. The valid range for the above example is computed as [0.000000000000001001, 0.000000000000000999] if there are 4 significant figures. Thus, 0 should fail, but it is unintuitive.

  3. Comparisons of 0 with 0 rely on a integer overflow
    First of all, we should not be passing an invalid domain (0) to log10()
    Second of all, we should not be casting –Inf to integer then do a subtraction on it. This will cause an overflow.

  4. Comparisons with extremely small numbers will always return a failure
    Eg. assert_that_double(4.9406564584124654E-324, is_equal_to_double(4.9406564584124654E-324));
    Occurs because the calculated relative epsilon is smaller than the smallest real double value (represented by bits). This can be fixed by assigning the smallest real double as the relative epsilon, instead of letting the math go to 0

Note that issue 1 is a critical bug and should be fixed first (ASAP).

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

No branches or pull requests

2 participants