title: How to compare two double number and find smaler
body: <p>This class contains list of Rectangles and I need to find rectangle with smallest area.</p>
  
  <p>I've found that need to compare rectangles by area, but it has the double precision.
  I understand that my comparison remember the last one, but how we can do this checking here?</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>   /**
      * Gets the Rectangle with the smallest area
      * @return the rectangle with the smallest area or null if
      * there are no rectangles
      */
     public Rectangle smallestArea()
     {        
         if (list.size() == 0) return null;
  
         Rectangle smallest = list.get(0);           
         double smallestArea = smallest.getWidth() * smallest.getHeight();
  
         for (int i = 1; i &lt; list.size(); i++) {
             Rectangle next = list.get(i);
             double nextArea = next.getWidth() * next.getHeight();
  
             if ((nextArea - smallestArea) &lt; 0) smallest = next;             
         }
  
         return smallest;
     }
  </code></pre>
  
  <p>How to solve this issue?</p>