Returns int() of val if val is not convertable to int use default
    instead

    :param val:
    :param default:
512507
def safe_int(val, default=None):
    

    try:
        val = int(val)
    except (ValueError, TypeError):
        val = default

    return val
1159141
private int parseInteger(String value, int defaultValue)
	{
		try
		{
			return Integer.parseInt(value);
		}
		catch (NumberFormatException e)
		{
			return defaultValue;
		}
	}
18512
public static int toInteger(Object value, int defaultValue) {
		if (value == null || value.toString().trim().equals("")) {
			return defaultValue;
		}
		if (value instanceof Integer) {
			return (Integer) value;
		}
		return (int) JKConversionUtil.toDouble(value);
	}
625040
public static int getInt(JsonObject object, String field, int defaultValue) {
        final JsonValue value = object.get(field);
        if (value == null || value.isNull()) {
            return defaultValue;
        } else {
            return value.asInt();
        }
    }
1244641
def safe_int(string, default=None):
    
    value = safe_float(string, default)
    if value is not None:
        value = int(value)
    return value
975200
public int getInt(String key, int defaultValue) {
    if (containsKey(key)) {
      return Integer.parseInt(get(key));
    } else {
      return defaultValue;
    }
  }
188812
def normalize_val(val):
    
    if is_unicode(val) and val.isdigit():
        return int(val)
    elif isinstance(val, list):
        return ','.join(val)
    elif val is None:
        return ''

    return val
1292864
def _parse_int(value, default=None):
    
    if value is None:
        return default
    try:
        return int(value)
    except ValueError:
        print "Couldn't cast value to `int`."
        return default
1183962
def __int(value):
    ''''''
    valid, _value = False, value
    try:
        _value = int(value)
        valid = True
    except ValueError:
        pass
    return (valid, _value, 'integer')
534555
def set_float(val):
    
    out = None
    if not val in (None, ''):
        try:
            out = float(val)
        except ValueError:
            return None
        if numpy.isnan(out):
            out = default
    return out
780917
def to_int(self, number, default=0):
        
        try:
            return int(number)
        except (KeyError, ValueError):
            return self.to_int(default, 0)
651961
public static int intVal(String val, int defaultValue) {
        try {
            return NumberUtils.createNumber(val).intValue();
        } catch (Exception e) {
            log.warn("intVal(String, int) throw {}, return defaultValue = {}", e, defaultValue);
            return defaultValue;
        }
    }
212835
def as_int(self, val: Tuple[str]) -> int:
        """"""
        res = 0
        try:
            for b in val:
                res += 1 << self.bit[b]
        except KeyError:
            return None
        return res
995585
private int getIntValue(int stackDepth, int defaultValue) {
        if (stack.getStackDepth() < stackDepth) {
            return defaultValue;
        }
        OpcodeStack.Item it = stack.getStackItem(stackDepth);
        Object value = it.getConstant();
        if (!(value instanceof Integer)) {
            return defaultValue;
        }
        return ((Number) value).intValue();
    }
850576
def int_pair(s, default=(0, None)):
    
    s = re.split(r'[^0-9]+', str(s).strip())
    if len(s) and len(s[0]):
        if len(s) > 1 and len(s[1]):
            return (int(s[0]), int(s[1]))
        return (int(s[0]), default[1])
    return default
512081
def _parse_float(value, default=None):
    
    if value is None:
        return default
    try:
        return float(value)
    except ValueError:
        print "Couldn't cast value to `float`."
        return default
337847
function(val) {

    if (val === undefined) {
      return "undefined";
    }
    if (val === null) {
      return "null";
    }

    let type = typeof val;

    if (type === "object") {
      type = getClass(val).toLowerCase();
    }

    if (type === "number") {
      return val.toString().indexOf(".") > 0 ?
        "float" :
        "integer";
    }

    return type;
  }