Prevent division by zero.

This commit is contained in:
asofold 2012-10-02 17:04:24 +02:00
parent af8623ee81
commit a07202c1ff

View File

@ -111,7 +111,7 @@ public class CheckUtils {
* @return result true if the two Strings are similar, false otherwise
*/
public static boolean isSimilar(final String s, final String t, final float threshold) {
return 1.0f - (float) levenshteinDistance(s, t) / Math.max(s.length(), t.length()) > threshold;
return 1.0f - (float) levenshteinDistance(s, t) / Math.max(1.0, Math.max(s.length(), t.length())) > threshold;
}
/**