I mean that Double#compare has a very strange implementation, you can use something like this http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/math/DoubleMath.html#fuzzyCompare(double, double, double)