title: How to test if a double is zero?
body: <p>I have some code like this:</p>
  
  <pre><code>class Foo {
      public double x;
  }
  
  void test() {
      Foo foo = new Foo();
  
      // Is this a valid way to test for zero? 'x' hasn't been set to anything yet.
      if (foo.x == 0) {
  
      }
  
      foo.x = 0.0;
  
      // Will the same test be valid?
      if (foo.x == 0) {
  
      }
  }
  </code></pre>
  
  <p>I basically want to avoid a divide-by-zero exception in the future.</p>
  
  <p>Thanks</p>