             // "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

    /**
     *  Finds a solution (x,y) for the equation abs(a*x + c*y) = w such that
     *  abs(b*x +d*y) is minimized.
     *  If there is infinite number of solutions, x and y are picked to be
     *  as close as possible.
     * 
     *  Doesn't handle cases where <code>a</code> or <code>c</code> are zero.
