Menu

#236 neg_epsilon != - epsilon in Utility

v5.x
closed
galago (57)
1
2014-06-19
2014-05-01
Weize Kong
No

Is there any particular reason why neg_epsilon != -epsilon in org.lemurproject.galago.tupleflow.Utility:

epsilon = 0.5 * Math.pow(10, -10);
neg_epsilon = -1.0 * Math.pow(10, -10);

They are used in Utility.compare(double, double), and will cause java.lang.IllegalArgumentException (Comparison method violates its general contract) when using Utility.compare in sorting.

public static int compare(double one, double two) {
double result = one - two;

if (result > epsilon) {
  return 1;
}
if (result < neg_epsilon) {
  return -1;
}
return 0;

}

Discussion

  • David Fisher

    David Fisher - 2014-05-02
    • assigned_to: Weize Kong
     
  • David Fisher

    David Fisher - 2014-06-10

    to ship in 6/2014 release.

     
  • David Fisher

    David Fisher - 2014-06-10
    • status: open --> accepted
     
  • David Fisher

    David Fisher - 2014-06-19
    • Status: accepted --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB