title: Comparator with double type
body: <p>I have written the following code:</p>
  
  <pre><code>public class NewClass2 implements Comparator&lt;Point&gt;
  {
      public int compare(Point p1, Point p2)
      {
          return (int)(p1.getY() - p2.getY());
      }
  }
  </code></pre>
  
  <p>If I let's say have two double numbers, <code>3.2 - 3.1</code>, the difference should be <code>0.1</code>. When I cast the number to an int, however, the difference ends up as <code>0</code>, which is not correct.</p>
  
  <p>I therefore need <code>compare()</code> to return a double, not an int. The problem is, my <code>getX</code> field is a double. How can I solve this problem?</p>