title: What should be the epsilon value when performing double value equal comparison
body: <p>Here is the output for the below program.</p>
  
  <pre><code>value is : 2.7755575615628914E-17
  Double.compare with zero : 1
  isEqual with zero : true
  </code></pre>
  
  <p><strong>My question is, what should be an epsilon value? Is there any robust way to obtain the value, instead of picking a number out from the sky.</strong></p>
  
  <hr>
  
  <pre><code>package sandbox;
  
  /**
   *
   * @author yccheok
   */
  public class Main {
  
      /**
       * @param args the command line arguments
       */
      public static void main(String[] args) {
          double zero = 1.0/5.0 + 1.0/5.0 - 1.0/10.0 - 1.0/10.0 - 1.0/10.0 - 1.0/10.0;
          System.out.println("value is : " + zero);
          System.out.println("Double.compare with zero : " + Double.compare(zero, 0.0));
          System.out.println("isEqual with zero : " + isEqual(zero, 0.0));
      }
  
      public static boolean isEqual(double d0, double d1) {
          final double epsilon = 0.0000001;
          return d0 == d1 ? true : Math.abs(d0 - d1) &lt; epsilon;
      }
  }
  </code></pre>