Convert a string to a number.
    Returns an integer if the string represents an integer, a floating
    point number if the string is a real number, or the string unchanged
    otherwise.
196885
def _number(text):
    '''
    
    '''
    if text.isdigit():
        return int(text)
    try:
        return float(text)
    except ValueError:
        return text
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
1177594
function parseNumber( str ) {
	var v = parseFloat( str );
	if ( isnan( v ) ) {
		return new TypeError( 'invalid value. Unable to parse string as a number. Value: `' + str + '`.' );
	}
	return v;
}
1340074
def toint(number):
    
    if isinstance(number, float):
        number = round(number, 0)
    return int(number)
819645
def int_to_string(number, alphabet, padding=None):
    
    output = ""
    alpha_len = len(alphabet)
    while number:
        number, digit = divmod(number, alpha_len)
        output += alphabet[digit]
    if padding:
        remainder = max(padding - len(output), 0)
        output = output + alphabet[0] * remainder
    return output[::-1]
1355226
def convert_to_decimal(string):
    
    number_or_fraction = '(?:\d{1,2}) | (?:\d{1,10} \\ \d{1,10})'
    m = re.compile('''\[?\s?            # opening bracket
                    \d{{1,2}}\s?,\s?    # first number
                    {0} \s?,\s?         # second number (can be a fraction)
                    {0} \s?,\s?         # third number (can be a fraction)
                    \]?\s?              # closing bracket
                    '''.format(number_or_fraction), re.VERBOSE)
    if not m.match(string):
        raise ValueError

    h, m, s = re.sub('\[|\]', '', string).split(', ')
    result = int(h)
    if '/' in m:
        m = m.split('/')
        result += int(m[0]) * 1.0 / int(m[1]) / 60
    else:
        result += int(m) * 1.0 / 60
    if '/' in s:
        s = s.split('/')
        result += int(s[0]) * 1.0 / int(s[1]) / 3600
    else:
        result += int(s) * 1.0 / 60
    return result
726555
def validate_integer(option, value):
    
    if isinstance(value, integer_types):
        return value
    elif isinstance(value, string_type):
        try:
            return int(value)
        except ValueError:
            raise ValueError("The value of %s must be "
                             "an integer" % (option,))
    raise TypeError("Wrong type for %s, value must be an integer" % (option,))
1188922
def _convert_hex_str_to_int(val):
    """"""
    if val is None:
        return None

    hex_num = int(val, 16)
    #  ensure it fits into 64-bit
    if hex_num > 0x7FFFFFFFFFFFFFFF:
        hex_num -= 0x10000000000000000

    assert -9223372036854775808 <= hex_num <= 9223372036854775807
    return hex_num
278681
function (num) {
      switch (typeof num) {
        case 'number':
          return num;
        case 'string':
          if (!isNaN(num)) {
            return num.indexOf('.') > -1 ? parseFloat(num) : parseInt(num, 10);
          }
      }

      return num;
    }
906389
function(num) {
    num = parseInt(num);

    if (num < 10) {
      num = '0' + num;
    } else {
      num = num.toString();
    }

    return num;
  }
477528
def string_to_numeric_char_reference(string):
    
    out = ""
    for char in string:
        out += "&#" + str(ord(char)) + ";"
    return out
1191226
private Number parseNumber(String string) {
		if (string.length() > 2 && string.charAt(0) == '0' && string.charAt(1) == 'x') {
			return Long.parseLong(string.substring(2), 16);
		}
		return Double.parseDouble(string);
	}
407660
function toInteger(input) {
  if (_.isNumber(input)) {
    input = Math.round(input);
  }
  else if (_.isString(input) && input !== "") {
    input = Math.round(input.replace(/[^0-9-.]/g, ""));
  }
  else if (_.isBoolean(input)) {
    input = input ? 1 : 0;
  }
  else {
    input = null;
  }

  return _.isNaN(input) || input === null ? null : input;
}
1073332
public Integer convertStringToInteger(String value) {
        Integer result;
        try {
            result = Integer.valueOf(value);
        } catch (NumberFormatException e) {
            result = DEFAULT_INT_VALUE;
        }
        return result;

    }
1133907
function primitive(str) {
	if (typeof str !== 'string')
		return str
	if (str === 'null')
		return null
	if (str === 'undefined')
		return undefined
	if (str === 'true')
		return true
	if (str === 'false')
		return false
	if (str === 'true')
		return true
	if (str === 'NaN')
		return NaN
	//if (str === 'Infinity')
	//	return Number.POSITIVE_INFINITY
	let ret
	if (str.indexOf('.') >= 0)
		ret = Number.parseFloat(str)
	else
		ret = Number.parseInt(str)
	if (!Number.isNaN(ret))
		return ret
	return str
}
1240468
def get_numeric_value(string_value):
    
    num_chars = ['.', '+', '-']
    number = ''
    for c in string_value:
        if c.isdigit() or c in num_chars:
            number += c
    return number
130258
def _string_to_int(self, string):
        
        number = 0
        for char in string[::-1]:
            number = number * self._alpha_len + self._alphabet.index(char)
        return number