             // "make x and y as close as possible": y = -w / ( a + c );  
             // "minimize abs(bx + dy)": y = -b * w / det    
             // "preserve aspect ratio": y = w / ( a * preferredX / preferredY + c );
-            if (det == 0)
+            if (Math.abs(det) < 1.0e-9)
             {
-                // There is infinate number of solutions, lets pick x == y
+                // There is infinite number of solutions, lets pick x == y
                 y = -w / ( a + c );
             }
             else

            // "make x and y as close as possible": y = w / ( a + c );  
            // "minimize abs(bx + dy)": y = b * w / det    
            // "preserve aspect ratio": y = w / ( a * preferredX / preferredY + c );
            if (det == 0)
            {
                // There is infinate number of solutions, lets pick x == y
                y = w / ( a + c );
            }
            else

     *  x and y are restricted by <code>minX</code>, <code>maxX</code> and
     *  <code>minY</code>, <code>maxY</code>.
     * 
     *  When there is infinite number of solutions, the function will
     *  calculate x and y to be as close as possible.
     * 
     *  The functon assumes <code>minX >= 0</code> and <code>minY >= 0</code>
