/*
The result is a negative integer if str1 is _numerically_ less than str2.
The result is a positive integer if str1 is _numerically_ greater than str2.
The result is zero if the strings are _numerically_ equal.
769489
public static int versionCompare(String str1, String str2) {
        String[] vals1 = str1.split("\\.");
        String[] vals2 = str2.split("\\.");
        int i = 0;
        // set index to first non-equal ordinal or length of shortest version string
        while (i < vals1.length && i < vals2.length && vals1[i].equals(vals2[i])) {
            i++;
        }
        // compare first non-equal ordinal number
        if (i < vals1.length && i < vals2.length) {
            int diff = Integer.valueOf(vals1[i]).compareTo(Integer.valueOf(vals2[i]));
            return Integer.signum(diff);
        }
        // the strings are equal or one string is a substring of the other
        // e.g. "1.2.3" = "1.2.3" or "1.2.3" < "1.2.3.4"
        return Integer.signum(vals1.length - vals2.length);
    }
1298188
public static int compare( String s1, String s2)
	{
		if (s1 == null && s2 == null)
		{
			return 0;
		}
		else if (s1 == null && s2 != null)
		{
			return -1;
		}
		else if (s1 != null && s2 == null)
		{
			return 1;
		}
		else
		{
			return s1.compareTo(s2);
		}
	}
183290
public static int difference(String s1, String s2) {

        /** @todo: check if this is the standard algorithm */
        if ((s1 == null) || (s2 == null)) {
            return 0;
        }

        s1 = soundex(s1);
        s2 = soundex(s2);

        int e = 0;

        for (int i = 0; i < 4; i++) {
            if (s1.charAt(i) != s2.charAt(i)) {
                e++;
            }
        }

        return e;
    }
702392
def _isnumber(string):
    
    if not _isconvertible(float, string):
        return False
    elif isinstance(string, (_text_type, _binary_type)) and (
            math.isinf(float(string)) or math.isnan(float(string))):
        return string.lower() in ['inf', '-inf', 'nan']
    return True
994121
public static boolean isNumeric(String str, int beginIndex, int endIndex)
    {
        for ( int i = beginIndex; i < endIndex; i++ ) {
            char chr = str.charAt(i);
            if ( ! StringUtil.isEnNumeric(chr) ) {
                return false;
            }
        }

        return true;
    }
888961
function ( num1, num2 ) {
		if ( isNaN( num1 ) || isNaN( num2 ) ) {
			throw new Error( label.error.expectedNumber );
		}

		return Math.abs( num1 - num2 );
	}
808225
function fuzzyStringCompare(a, b, tolerence) {
	if (a == b) return true;

	var as = stripNoise(a);
	as = as.toLowerCase();
	if (as.length > 255) as = as.substr(0, 255);

	var bs = stripNoise(b);
	bs = bs.toLowerCase();
	if (bs.length > 255) bs = bs.substr(0, 255);

	if (tolerence == undefined && levenshtein(as, bs) < 10) return true;
	if (tolerence && levenshtein(as, bs) <= tolerence) return true;
}
582023
def validate_non_negative_int_or_basestring(option, value):
    
    if isinstance(value, integer_types):
        return value
    elif isinstance(value, string_type):
        try:
            val = int(value)
        except ValueError:
            return value
        return validate_non_negative_integer(option, val)
    raise TypeError("Wrong type for %s, value must be an "
                    "non negative integer or a string" % (option,))
286159
public char match(String str1, String str2) {
        if (str1 == null || str2 == null)
            return IMappingElement.IDK;
        if (str1.equals(str2)) {
            return IMappingElement.EQUIVALENCE;
        } else
            return IMappingElement.IDK;
    }
214176
function roundInt(str, precision = +Infinity) {
  if (!isNumStr(str, 10)) throw new Error('in roundInt, string must be an integer in base 10.');
  if (precision <= 0) throw new Error('in roundInt, precision must be greater than 0.');
  const minus = String.fromCharCode(consts.minus);
  
  str = rectify(str);

  // If the number is negative, ignore the negative sign for now.
  let start = (str[0] == minus) ? 1 : 0;

  // If the length of the number is less than or equal to precision, return the number.
  if (str.length - start <= precision) return str;

  // Get the significant part, the digit following, and the remaining digits.
  let sigPart = str.slice(start, precision + start);
  let nextDigit = charToVal(str[precision + start]);
  let remainder = str.slice(precision + start + 1);

  // Decide whether to increment the significant part; round half to even.
  let increment = false;
  if (nextDigit > 5) increment = true;
  else if (nextDigit == 5) {
    if (!isEntirely(remainder, consts.alphabet[0])) increment = true;  // inc if remainder is nonzero
    else {
      let lSigDigit = charToVal(sigPart[precision - 1]); // otherwise inc if it will give you an even number.
      if (lSigDigit % 2) increment = true;
    }
  }
  if (increment) sigPart = incInt(sigPart);

  // The rounded value is the significant part padded with zeros.
  let roundedLength = sigPart.length + 1 + remainder.length;
  let rounded = sigPart.padEnd(roundedLength, consts.alphabet[0]);

  // If the value was negative, replace the negative sign.
  rounded = (str[0] == minus) ? minus + rounded : rounded;

  return rounded;
}
521441
function(a,b) {
		var tA, tB, i;
		for (i=0; i<a.length; ++i) {
			tA = typeof a[i]; tB = typeof b[i];
			if (tA === tB) {
				if ((tA === 'number') || (tA === 'string') || (tA === 'boolean')) {
					if (a[i] < b[i]) return -1;
					if (a[i] > b[i]) return 1;
					if (a[i] !== b[i]) return 1;
				  /*if (a[i] == b[i]) continue;*/
				} else {
					if (a[i] === b[i]) continue;
					return 1;
				}
			} else {
				return 1;
			}
		}
		return 0;
	}
1358693
function isNumeric(value) {
  if (_.isNumber(value)) {
    return true;
  }
  if (_.isString(value)) {
    if (!isFinite(value)) {
      return false;
    }
    // str is a finite number, but not all number strings should be numbers
    // If the string starts with 0, is more than 1 character, and does not have a period, it should stay a string
    // It could be an account number for example
    if (value[0] === '0' && value.length > 1 && value.indexOf('.') === -1) {
      return false;
    }

    return true;
  }
  return false;
}
140377
function compare(buf1, buf2){
    if (buf1.length !== buf2.length)
        return buf1.length - buf2.length;

    for (var i = 0; i < buf1.length; i++)
        if (buf1[i] !== buf2[i])
            return buf1[i] - buf2[i];

    return 0;
}
1122575
public static boolean isNumber(String str) {
		if (StrUtil.isBlank(str)) {
			return false;
		}
		char[] chars = str.toCharArray();
		int sz = chars.length;
		boolean hasExp = false;
		boolean hasDecPoint = false;
		boolean allowSigns = false;
		boolean foundDigit = false;
		// deal with any possible sign up front
		int start = (chars[0] == '-') ? 1 : 0;
		if (sz > start + 1) {
			if (chars[start] == '0' && chars[start + 1] == 'x') {
				int i = start + 2;
				if (i == sz) {
					return false; // str == "0x"
				}
				// checking hex (it can't be anything else)
				for (; i < chars.length; i++) {
					if ((chars[i] < '0' || chars[i] > '9') && (chars[i] < 'a' || chars[i] > 'f') && (chars[i] < 'A' || chars[i] > 'F')) {
						return false;
					}
				}
				return true;
			}
		}
		sz--; // don't want to loop to the last char, check it afterwords
				// for type qualifiers
		int i = start;
		// loop to the next to last char or to the last char if we need another digit to
		// make a valid number (e.g. chars[0..5] = "1234E")
		while (i < sz || (i < sz + 1 && allowSigns && !foundDigit)) {
			if (chars[i] >= '0' && chars[i] <= '9') {
				foundDigit = true;
				allowSigns = false;

			} else if (chars[i] == '.') {
				if (hasDecPoint || hasExp) {
					// two decimal points or dec in exponent
					return false;
				}
				hasDecPoint = true;
			} else if (chars[i] == 'e' || chars[i] == 'E') {
				// we've already taken care of hex.
				if (hasExp) {
					// two E's
					return false;
				}
				if (!foundDigit) {
					return false;
				}
				hasExp = true;
				allowSigns = true;
			} else if (chars[i] == '+' || chars[i] == '-') {
				if (!allowSigns) {
					return false;
				}
				allowSigns = false;
				foundDigit = false; // we need a digit after the E
			} else {
				return false;
			}
			i++;
		}
		if (i < chars.length) {
			if (chars[i] >= '0' && chars[i] <= '9') {
				// no type qualifier, OK
				return true;
			}
			if (chars[i] == 'e' || chars[i] == 'E') {
				// can't have an E at the last byte
				return false;
			}
			if (chars[i] == '.') {
				if (hasDecPoint || hasExp) {
					// two decimal points or dec in exponent
					return false;
				}
				// single trailing decimal point after non-exponent is ok
				return foundDigit;
			}
			if (!allowSigns && (chars[i] == 'd' || chars[i] == 'D' || chars[i] == 'f' || chars[i] == 'F')) {
				return foundDigit;
			}
			if (chars[i] == 'l' || chars[i] == 'L') {
				// not allowing L with an exponent
				return foundDigit && !hasExp;
			}
			// last character is illegal
			return false;
		}
		// allowSigns is true iff the val ends in 'E'
		// found digit it to make sure weird stuff like '.' and '1E-' doesn't pass
		return !allowSigns && foundDigit;
	}
762018
private int convertNonNegativeInteger(String str) {
    str = str.trim();
    DecimalDatatype decimal = new DecimalDatatype();
    if (!decimal.lexicallyAllows(str))
      return -1;
    // Canonicalize the value
    str = decimal.getValue(str, null).toString();
    // Reject negative and fractional numbers
    if (str.charAt(0) == '-' || str.indexOf('.') >= 0)
      return -1;
    try {
      return Integer.parseInt(str);
    }
    catch (NumberFormatException e) {
      // Map out of range integers to MAX_VALUE
      return Integer.MAX_VALUE;
    }
  }
25442
def match_strings(str1, str2):
    
    i = 0
    min_len = len(str1) if len(str1) < len(str2) else len(str2)
    while i < min_len and str1[i] == str2[i]: i += 1
    return i
540426
def _mpfr_get_str2(base, ndigits, op, rounding_mode):
    
    digits, exp = mpfr.mpfr_get_str(base, ndigits, op, rounding_mode)
    negative = digits.startswith('-')
    if negative:
        digits = digits[1:]
    return negative, digits, exp